2 #############################################################################
3 ## Name: samples/minimal/minimal.pl
4 ## Purpose: Minimal wxPerl sample
5 ## Author: Mattia Barbon
8 ## RCS-ID: $Id: minimal.pl 2455 2008-08-31 11:16:05Z mbarbon $
9 ## Copyright: (c) 2000, 2004-2006, 2008 Mattia Barbon
10 ## Licence: This program is free software; you can redistribute it and/or
11 ## modify it under the same terms as Perl itself
12 #############################################################################
19 use base qw(Wx::Frame);
21 use Wx::Event qw(EVT_MENU);
23 # Parameters: title, position, size
25 my( $class, $label ) = @_;
26 my $this = $class->SUPER::new( undef, -1, $label );
28 # load an icon and set it as frame icon
29 $this->SetIcon( Wx::GetWxPerlIcon() );
32 my $mfile = Wx::Menu->new;
33 my $mhelp = Wx::Menu->new;
35 my( $ID_ABOUT, $ID_EXIT ) = ( 1, 2 );
36 $mhelp->Append( $ID_ABOUT, "&About...\tCtrl-A", "Show about dialog" );
37 $mfile->Append( $ID_EXIT, "E&xit\tAlt-X", "Quit this program" );
39 my $mbar = Wx::MenuBar->new;
41 $mbar->Append( $mfile, "&File" );
42 $mbar->Append( $mhelp, "&Help" );
44 $this->SetMenuBar( $mbar );
46 # declare that events coming from menu items with the given
47 # id will be handled by these routines
48 EVT_MENU( $this, $ID_EXIT, 'OnQuit' );
49 EVT_MENU( $this, $ID_ABOUT, 'OnAbout' );
54 # called when the user selects the 'Exit' menu item
56 my( $this, $event ) = @_;
62 use Wx qw(wxOK wxICON_INFORMATION wxVERSION_STRING);
64 # called when the user selects the 'About' menu item
66 my( $this, $event ) = @_;
68 # display a simple about box
69 my $message = sprintf <<EOT, $Wx::VERSION, wxVERSION_STRING;
70 This is the about dialog of minimal sample.
71 Welcome to wxPerl %.02f
74 Wx::MessageBox( $message, "About minimal", wxOK | wxICON_INFORMATION,
80 # create an instance of the Wx::App-derived class
81 my $app = Wx::SimpleApp->new;
82 my $frame = MyFrame->new( "Minimal wxPerl app" );