Top Banner
Пользовательский интерфейс на Perl
16

Perl gui

Jun 24, 2015

Download

Technology

umnix

Using Perl for GUI in corporate software
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Perl gui

Пользовательский интерфейс на Perl

Page 2: Perl gui

Архитектура «Globus Professional»

Client App ServerDB

Page 3: Perl gui

Вход в «Globus Professional»

Page 4: Perl gui

Клиентское приложение

Page 5: Perl gui

Класс приложения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;}

Page 6: Perl gui

Класс окна (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" );

Page 7: Perl gui

Класс окна (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;}

Page 8: Perl gui

Обработчики# 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 );

}

Page 9: Perl gui

Запуск приложения

package main;

# create an instance of the Wx::App-derived classmy $app = MyApp->new();

# start processing events$app->MainLoop();

Page 10: Perl gui

Конструктор АРМ

Page 11: Perl gui

АРМ регистратора заявок пользователей

Page 12: Perl gui

Инструмент отладки перлового кода ( KIT )

Page 13: Perl gui

Регистрация ActiveX-компонентperl -Mblib -MWx::ActiveX::Template -e"run_wxactivex_template();"

Регистрация ActiveX-компонент

Page 14: Perl gui

Работа с компонентом

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();

Page 15: Perl gui

Common Language Runtime (CLR)

use Win32::CLR;

Win32::CLR->load_from( $path );

$fineReaderWrapper = Win32::CLR->create_instance( "EISFREWrapper.Wrapper" );

$fineReaderWrapper->setOutputFormat( $format );

Page 16: Perl gui

Ссылки

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