-
#!/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::Event qw(EVT_BUTTON);
-
sub new {
-
my $ref = shift;
-
my $self = $ref->SUPER::new(
-
undef,
-
-1,
-
'wxperl rules',
-
[-1, -1],
-
[500, 300],
-
);
-
-
my $panel = Wx::Panel->new($self);
-
-
my $text = Wx::StaticText->new(
-
$panel,
-
-1,
-
"This is the text",
-
[200,200],
-
);
-
-
my $button = Wx::Button->new(
-
$panel,
-
-1,
-
'click me',
-
[-1, -1],
-
[100, 50],
-
);
-
-
EVT_BUTTON($self, $button, &OnClick);
-
-
return $self;
-
}
-
-
sub OnClick {
-
say "hello";
-
}
-
-
package MyApp;
-
use base 'Wx::App';
-
sub OnInit {
-
my $frame = MyFrame->new;
-
$frame->Show;
-
}
-
-
package main;
-
my $app = MyApp->new;
- $app->MainLoop;