Perl 语言实现一个窗体

前端之家收集整理的这篇文章主要介绍了Perl 语言实现一个窗体前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

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;

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

猜你在找的Perl相关文章