#!/usr/bin/perl use strict; use warnings; use Wx; package MyFrame; use base 'Wx::Frame'; use Wx::Event qw(EVT_BUTTON); sub new { my $ref = shift; my $self = $ref->SUPER::new( undef, #Parent Window -1, #Window ID (-1 means any) 'wxPerl', #Window Title [-1, -11], #Default Position [250, 250], #size ); #create panel my $panel = Wx::Panel->new ( $self, #parent window -1, #id ); #create button my $button = Wx::Button->new( $panel, # Parent Panel -1, # id 'Click Me!', # label [30, 20], # position [-1, -1], # default size ); my $timer = Wx::Timer->new( $self, # Parent Frame -1, # Timer ID ); $timer->Start(1); EVT_TIMER $self, $timer, \&do_stuff; EVT_BUTTON $self, $button, \&on_click_button; return $self; } sub on_click_button { my ($self, $event) = @_; $self->SetTitle( 'Clicked'); } sub do_stuff { #get current focus Id; #determine if the ID has changed #etc } package MyTimer; use base 'Wx::Timer'; sub new { my $self = shift; my $timer = Wx::Timer->wxTimer(); return $timer; } 1; package MyApp; use base 'Wx::App'; sub OnInit { my $timer = MyTimer->new; $timer->Start(1); my $frame = MyFrame->new; $frame->Show(1); } package main; my $app = MyApp->new; $app->MainLoop;