Ask

 view release on metacpan or  search on metacpan

lib/Ask/Wx.pm  view on Meta::CPAN

use 5.008008;
use strict;
use warnings;

package Ask::Wx;

our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION   = '0.015';

use Moo;
use Path::Tiny 'path';
use Wx;
use namespace::autoclean;

with 'Ask::API';

sub is_usable {
	my ( $self ) = @_;
	return !!$ENV{'DISPLAY'};
}

sub quality {
	return 10;    # raise to 50 once multi file selection implemented
}

sub info {
	my ( $self, %o ) = @_;
	$o{messagebox_icon} = Wx::wxICON_INFORMATION()
		unless defined $o{messagebox_icon};
	$o{messagebox_buttons} = Wx::wxOK()    unless defined $o{messagebox_buttons};
	$o{text}               = ''            unless exists $o{text};
	$o{title}              = 'Information' unless exists $o{title};
	Wx::MessageBox(
		$o{text},
		$o{title},
		$o{messagebox_icon} | $o{messagebox_buttons},
	);
} #/ sub info

sub warning {
	my ( $self, %o ) = @_;
	$self->info( messagebox_icon => Wx::wxICON_WARNING(), title => 'Warning', %o );
}

sub error {
	my ( $self, %o ) = @_;
	$self->info( messagebox_icon => Wx::wxICON_ERROR(), title => 'Error', %o );
}

sub question {
	my ( $self, %o ) = @_;
	Wx::wxYES() == $self->info(
		title              => 'Question',
		messagebox_icon    => Wx::wxICON_QUESTION(),
		messagebox_buttons => Wx::wxYES_NO(),
		%o,
	);
}

sub entry {
	my ( $self, %o ) = @_;
	
	$o{text}       = ''           unless exists $o{text};
	$o{title}      = 'Text extry' unless exists $o{title};
	$o{entry_text} = ''           unless exists $o{entry_text};
	
	$o{hide_text}
		? Wx::GetPasswordFromUser( $o{text}, $o{title}, $o{entry_text} )
		: Wx::GetTextFromUser( $o{text}, $o{title}, $o{entry_text} );
} #/ sub entry

sub file_selection {
	my ( $self, %o ) = @_;



( run in 1.283 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )