Changeset 73
- Timestamp:
- 08/19/08 09:06:09 (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
-
MANIFEST (modified) (1 diff)
-
eg/wx_demo/01_prompt.pl (modified) (1 diff)
-
eg/wx_demo/03_filename.pl (added)
-
lib/Padre/Demo.pm (modified) (2 diffs)
-
lib/Padre/Demo/Frame.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/MANIFEST
r72 r73 41 41 42 42 eg/wx_demo/01_prompt.pl 43 eg/wx_demo/03_filename.pl 43 44 44 45 share/docview/print.xpm -
trunk/eg/wx_demo/01_prompt.pl
r72 r73 10 10 11 11 sub main { 12 open_frame(); 12 13 my $name = prompt("What is your name?\n"); 13 14 print_out("How are you $name today?\n"); 14 15 my $filename = promp_input_file("Select source file");16 print_out("The file you selected is $filename\n");17 15 18 16 return; -
trunk/lib/Padre/Demo.pm
r72 r73 8 8 use Padre::Demo::App; 9 9 10 our @EXPORT = qw(prompt print_out promp_input_file close_app );10 our @EXPORT = qw(prompt print_out promp_input_file close_app open_frame); 11 11 12 use Wx qw(:everything); 13 use Wx::STC (); 14 use Wx::Event qw(:everything); 15 16 =head1 NAME 17 18 Padre::Demo - temporary name of a Zenity clone in wxPerl 19 20 =head1 SYNOPIS 21 22 use Padre::Demo; 23 24 Padre::Demo->run(\&main); 25 26 sub main { 27 my $name = prompt("What is your name?\n"); 28 print_out("How are you $name today?\n"); 29 30 return; 31 } 32 33 Command line: 34 35 Not yet available. 36 37 =head1 General Options 38 39 There are some common option for every dialog 40 41 title 42 43 window-icon Not implemented 44 45 width 46 47 height 48 49 =cut 50 51 =head1 METHODS 52 53 Dialogs 54 55 =head2 prompt 56 57 Display a text entry dialog 58 59 =cut 12 60 sub prompt { 13 my $frame = $Padre::Demo::App::frame; 14 $frame->prompt(@_); 61 my ($text) = @_; 62 my $frame = $Padre::Demo::App::frame; 63 64 my $dialog = Wx::TextEntryDialog->new( $frame, $text, "", '' ); 65 if ($dialog->ShowModal == wxID_CANCEL) { 66 return; 67 } 68 my $resp = $dialog->GetValue; 69 $dialog->Destroy; 70 return $resp; 15 71 } 16 72 73 74 75 =head2 print_out 76 77 =cut 17 78 sub print_out { 18 79 my $frame = $Padre::Demo::App::frame; … … 20 81 } 21 82 83 =head2 promp_input_file 84 85 =cut 22 86 sub promp_input_file { 23 my $frame = $Padre::Demo::App::frame; 24 $frame->promp_input_file(@_); 87 my ($text) = @_; 88 my $frame = $Padre::Demo::App::frame; 89 90 my $dialog = Wx::FileDialog->new( $frame, $text, '', "", "*.*", wxFD_OPEN); 91 if ($^O !~ /win32/i) { 92 $dialog->SetWildcard("*"); 93 } 94 if ($dialog->ShowModal == wxID_CANCEL) { 95 return; 96 } 97 my $filename = $dialog->GetFilename; 98 my $default_dir = $dialog->GetDirectory; 99 100 return File::Spec->catfile($default_dir, $filename); 25 101 } 26 102 103 104 105 =head2 open_frame 106 107 =cut 108 sub open_frame { 109 110 } 111 112 113 =head2 close_app 114 115 =cut 27 116 sub close_app { 28 117 my $frame = $Padre::Demo::App::frame; 29 118 $frame->Close; 30 119 } 120 121 122 123 31 124 32 125 sub get_frame { -
trunk/lib/Padre/Demo/Frame.pm
r71 r73 14 14 my $output; 15 15 16 sub prompt {17 my ($self, $text) = @_;18 19 my $dialog = Wx::TextEntryDialog->new( $self, $text, "", '' );20 if ($dialog->ShowModal == wxID_CANCEL) {21 return;22 }23 my $resp = $dialog->GetValue;24 $dialog->Destroy;25 return $resp;26 }27 28 16 sub print_out { 29 17 my ($self, $text) = @_; 30 18 $output->AddText($text); 31 19 return; 32 }33 34 sub promp_input_file {35 my ($self, $text) = @_;36 37 my $dialog = Wx::FileDialog->new( $self, $text, '', "", "*.*", wxFD_OPEN);38 if ($^O !~ /win32/i) {39 $dialog->SetWildcard("*");40 }41 if ($dialog->ShowModal == wxID_CANCEL) {42 return;43 }44 my $filename = $dialog->GetFilename;45 my $default_dir = $dialog->GetDirectory;46 47 return File::Spec->catfile($default_dir, $filename);48 20 } 49 21 … … 60 32 ); 61 33 62 my $editor= Wx::StyledTextCtrl->new($self, -1, [-1, -1], [750, 700]);63 $ editor->SetMarginWidth(1, 0);34 $output = Wx::StyledTextCtrl->new($self, -1, [-1, -1], [750, 700]); 35 $output->SetMarginWidth(1, 0); 64 36 65 EVT_ACTIVATE($self, sub {on_activate($editor, @_) }); 66 67 # my $button = Wx::Button->new( $self, -1, "Run" ); 68 # Wx::Event::EVT_BUTTON( $self, $button, sub { 69 # my ( $self, $event ) = @_; 70 # print "preparing to popup window...\n"; 71 # Wx::MessageBox( "This is the smell of an Onion", "Title", wxOK|wxCENTRE, $self ); 72 # }); 73 # $self->SetSize($button->GetSizeWH); 37 EVT_ACTIVATE($self, \&on_activate); 74 38 75 39 Wx::Event::EVT_CLOSE( $self, sub { … … 82 46 83 47 sub on_activate { 84 my ($ editor, $frame, $event) = @_;48 my ($frame, $event) = @_; 85 49 86 $output = $editor;87 50 $frame->EVT_ACTIVATE(sub {}); 88 51 #$Padre::Demo::app->Yield;
Note: See TracChangeset
for help on using the changeset viewer.
