加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl 语言实现一个窗体

发布时间:2020-12-15 21:08:08 所属栏目:大数据 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 Myapp.pm#!/usr/bin/perl -wuse strict;# load wxPerl main moduleuse Wx;# every application must create an application objectpackage MyApp;use

以下代码由PHP站长网 52php.cn收集自互联网

现在PHP站长网小编把它分享给大家,仅供参考

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 AgaintF3" );

    $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;

以上内容由PHP站长网【52php.cn】收集整理供大家参考研究

如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读