-
#!/usr/bin/perl
-
-
#author: zhengsenlin
-
#date: 2013-03-06
-
#desc: Wx ok
-
-
use 5.016;
-
use strict;
-
use warnings;
-
use autodie;
-
use Wx;
-
-
package MyFrame;
-
use base 'Wx::Frame';
-
use Wx qw(
-
:id
-
:toolbar
-
wxNullBitmap
-
wxDefaultPosition
-
wxDefaultSize
-
wxDefaultPosition
-
wxDefaultSize
-
wxNullBitmap
-
wxTB_VERTICAL
-
wxSIZE
-
wxTE_MULTILINE
-
wxBITMAP_TYPE_BMP
-
);
-
-
use Wx::Event qw(
-
EVT_SIZE
-
EVT_MENU
-
EVT_COMBOBOX
-
EVT_UPDATE_UI
-
EVT_TOOL_ENTER
-
);
-
-
sub new {
-
my $ref = shift;
-
-
my $self = Wx::Frame->new(
-
undef,
-
-1,
-
'A Wx Frame',
-
[-1, -1],
-
[500, 300],
-
);
-
-
my( $ID_TOOLBAR, $ID_COMBO ) = ( 1 .. 100 );
-
-
my(
-
$IDM_FILE_OPEN,
-
$IDM_FILE_CLOSE,
-
) = ( 10_000 .. 10_100 );
-
-
my $file_menu = Wx::Menu->new();
-
-
my @file_menu_entries = ([$IDM_FILE_OPEN,"&OpentCtrl-O","Open" ],
-
['-'],
-
[wxID_EXIT, "E&xittCtrl-X", "Exit $0"]
-
);
-
-
foreach (@file_menu_entries) {
-
if ($$_[0] eq '-') {
-
$file_menu->AppendSeparator();
-
} else {
-
$file_menu->Append($$_[0],$$_[1],$$_[2])
-
}
-
}
-
my $menubar = Wx::MenuBar->new();
-
$menubar->Append ($file_menu, '&File');
-
$self->SetMenuBar ($menubar);
-
-
EVT_MENU( $self, wxID_EXIT, sub {$_[0]->Close( 1 )} );
-
-
return $self;
-
}
-
-
package MyApp;
-
use base 'Wx::App';
-
sub OnInit {
-
my $frame = MyFrame->new;
-
$frame->Show;
-
}
-
-
package main;
-
my $app = MyApp->new;
- $app->MainLoop;