2 #############################################################################
3 ## Name: samples/hello/hello.pl
4 ## Purpose: Hello wxPerl sample
5 ## Author: Mattia Barbon
8 ## RCS-ID: $Id: hello.pl 2057 2007-06-18 23:03:00Z mbarbon $
9 ## Copyright: (c) 2000, 2004, 2006 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_PAINT);
22 # this imports some constants
23 use Wx qw(wxDECORATIVE wxNORMAL wxBOLD);
24 use Wx qw(wxDefaultPosition);
29 # new frame with no parent, id -1, title 'Hello, world!'
30 # default position and size 350, 100
31 my $this = $class->SUPER::new( undef, -1, 'Hello, world!',
32 wxDefaultPosition , [350, 100] );
34 # create a new font object and store it
35 $this->{font} = Wx::Font->new( 40, wxDECORATIVE, wxNORMAL, wxBOLD, 0 );
36 # set background colour
37 $this->SetBackgroundColour( wxWHITE );
39 $this->SetIcon( Wx::GetWxPerlIcon() );
41 # declare that all paint events will be handled with the OnPaint method
42 EVT_PAINT( $this, \&OnPaint );
48 my( $this, $event ) = @_;
49 # create a device context (DC) used for drawing
50 my $dc = Wx::PaintDC->new( $this );
53 $dc->SetFont( $this->font );
54 # draw a friendly message
55 $dc->DrawText( 'Hello, world!', 10, 10 );
58 sub font { $_[0]->{font} }
62 my $app = Wx::SimpleApp->new;
63 my $frame = MyFrame->new;