Perl 语言实现一个窗体
时间:2011-01-20
来源:互联网
- Myapp.pm
- #!/usr/bin/perl -w
-
- use strict;
-
- # load wxPerl main module
- use Wx;
-
- # every application must create an application object
- package MyApp;
- use base qw(Wx::Frame Class::Accessor::Fast);
-
- use Wx qw(:textctrl :sizer :window :id);
- use Wx qw(wxDefaultPosition wxDefaultSize wxTheClipboard
- wxDEFAULT_FRAME_STYLE wxNO_FULL_REPAINT_ON_RESIZE wxCLIP_CHILDREN);
- use Wx::Event qw(EVT_TREE_SEL_CHANGED EVT_MENU EVT_CLOSE);
- use File::Slurp;
- use File::Basename qw();
- use File::Spec;
- use UNIVERSAL::require;
-
-
- sub new{
-
- my( $class ) = @_;
- my $self = $class->SUPER::new
- ( undef, -1, 'wxPerl demo', wxDefaultPosition, [ 800, 600 ],
- wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN );
-
- Wx::InitAllImageHandlers();
- my $bar = Wx::MenuBar->new;
- my $file = Wx::Menu->new;
- my $help = Wx::Menu->new;
- my $edit = Wx::Menu->new;
-
- $file->Append( wxID_EXIT, '' );
- $help->Append( wxID_ABOUT, '' );
-
- $edit->Append( wxID_COPY, '' );
- $edit->Append( wxID_FIND, '' );
- my $find_again = $edit->Append( -1, "Find Again\tF3" );
-
- $bar->Append( $file, "&File" );
- $bar->Append( $edit, "&Edit" );
- $bar->Append( $help, "&Help" );
-
- $self->SetMenuBar( $bar );
- $self->{menu_count} = $self->GetMenuBar->GetMenuCount;
- $self->SetIcon( Wx::GetWxPerlIcon() );
- $self->Show;
-
- }
-
-
- 1;
- ui.pl
-
- #!perl -w
- use MyApp;
- use Getopt::Long;
-
- GetOptions( 'show=s' => \( my $module ),
- 'help' => \( my $help ),
- 'list' => \( my $list ),
- ) or usage();
- usage() if $help;
-
-
- my $app = Wx::SimpleApp->new;
- my $locale = Wx::Locale->new( Wx::Locale::GetSystemLanguage );
- my $ui = MyApp->new;
-
- $ui->activate_module( $module ) if $module;
-
- if ($list) {
- print join "\n",
- sort
- map $_->title,
- grep $_->can( 'title' ),
- $ui->plugins;
-
- exit 0;
- }
- $app->MainLoop;
- exit 0;
作者: 阳光boyer 发布时间: 2011-01-20
不错,wx还是比较成熟的。
作者: 兰花仙子: 发布时间: 2011-01-20
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28