Пользовательский интерфейс на Perl
Mar 26, 2015
Пользовательский интерфейс на Perl
Архитектура «Globus Professional»
Client App ServerDB
Вход в «Globus Professional»
Клиентское приложение
Класс приложенияuse Wx;
# every program must have a Wx::App-derive classpackage MyApp;
use strict;use warnings;
our @ISA=qw(Wx::App);
# this is called automatically on object creationsub OnInit { my( $this ) = @_;
# create new MyFrame my $frame = MyFrame->new( "Minimal wxPerl app",
[ 50, 50 ], #position [ 450, 350 ] #size
);
# set it as top window (so the app will automatically close when # the last top window is closed) $this->SetTopWindow( $frame ); # show the frame $frame->Show( 1 );
1;}
Класс окна (1)
package MyFrame;
use strict;use warnings;
our @ISA=qw(Wx::Frame);
use Wx::Event qw(EVT_MENU);use Wx qw(wxBITMAP_TYPE_ICO wxMENU_TEAROFF);
# Parameters: title, position, sizesub new { my $class = shift; my $self = $class->SUPER::new( undef, -1, $_[0], $_[1], $_[2] );
# load an icon and set it as frame icon $self->SetIcon( Wx::GetWxPerlIcon() );
# create the menus my $mfile = Wx::Menu->new( undef, wxMENU_TEAROFF ); my $mhelp = Wx::Menu->new();
my( $ID_ABOUT, $ID_EXIT ) = ( 1, 2 ); $mhelp->Append( $ID_ABOUT, "&About...\tCtrl-A", "Show about dialog" ); $mfile->Append( $ID_EXIT, "E&xit\tAlt-X", "Quit this program" );
Класс окна (2)
my $mbar = Wx::MenuBar->new();
$mbar->Append( $mfile, "&File" ); $mbar->Append( $mhelp, "&Help" );
$self->SetMenuBar( $mbar );
# declare that events coming from menu items with the given # id will be handled by these routines EVT_MENU( $self, $ID_EXIT, \&OnQuit ); EVT_MENU( $self, $ID_ABOUT, \&OnAbout );
# create a status bar (note that the status bar that gets created # has three panes, see the OnCreateStatusBar callback below $self->CreateStatusBar( 1 ); # and show a message $self->SetStatusText( "Welcome to wxPerl!", 1 );
$self;}
Обработчики# this is an addition to demonstrate virtual callbacks...# it ignores all parameters and creates a status bar with three fieldssub OnCreateStatusBar { my $self = shift; my $status = Wx::StatusBar->new( $self, -1 );
$status->SetFieldsCount( 2 );
$status;}
# called when the user selects the 'Exit' menu itemsub OnQuit { my( $self, $event ) = @_;
# closes the frame $self->Close( 1 );}
use Wx qw(wxOK wxICON_INFORMATION wxVERSION_STRING);
# called when the user selects the 'About' menu itemsub OnAbout { my( $self, $event ) = @_;
# display a simple about box Wx::MessageBox( "This is the about dialog of minimal sample.\n" .
"Welcome to wxPerl " . $Wx::VERSION . "\n" . wxVERSION_STRING, "About minimal", wxOK | wxICON_INFORMATION, $ self );
}
Запуск приложения
package main;
# create an instance of the Wx::App-derived classmy $app = MyApp->new();
# start processing events$app->MainLoop();
Конструктор АРМ
АРМ регистратора заявок пользователей
Инструмент отладки перлового кода ( KIT )
Регистрация ActiveX-компонентperl -Mblib -MWx::ActiveX::Template -e"run_wxactivex_template();"
Регистрация ActiveX-компонент
Работа с компонентом
use Win32::OLE;use Win32::OLE::Const; use Win32::OLE::Variant;use Wx::ActiveX::RolledCalendar;
…$dlg->{'_Xcalendar'} = Wx::ActiveX::RolledCalendar->new( $dlg );$main_sizer->Add( $dlg->{'_Xcalendar'}, 1, &Wx::wxGROW|
&Wx::wxALL, 0 );$dlg->{'_calendar'} = $dlg->{'_Xcalendar'}->GetOLE();$dlg->{'_calendar'}->SetDate( $date );…$date = $dlg->{'_calendar'}->GetDate();….$dlg->{'_Xcalendar'}->Destroy();
Common Language Runtime (CLR)
use Win32::CLR;
Win32::CLR->load_from( $path );
$fineReaderWrapper = Win32::CLR->create_instance( "EISFREWrapper.Wrapper" );
$fineReaderWrapper->setOutputFormat( $format );
Ссылки
1. презентацияwww.umnix.com/upload/perlGUI.ppt
2. сайт компанииwww.eis.ru
3. www.wxwidgets.org4. wxperl.sourceforge.net5. cpan.org
6. [email protected]@eis.ru