#!/usr/bin/perl use Wx; ####################################### # # package MainFrame; # # define a frame inside the window # then a panel to draw controls on ####################################### use base qw(Wx::Frame); use Wx qw(wxDefaultPosition wxDefaultSize wxDEFAULT_FRAME_STYLE wxNO_FULL_REPAINT_ON_RESIZE wxCLIP_CHILDREN); use Wx::Event qw( EVT_BUTTON ); sub new { my $class = shift; my $self = $class->SUPER::new(@_); $self->{panel} = Wx::Panel->new($self, -1); $self->{txt} = Wx::StaticText->new($self->{panel}, 1, 'Test', [50,15]); # authorise button my $btnID = 'authBtn'; $self->{btn} = Wx::Button->new($self->{panel}, $btnID, 'Authorise', [50,50]); EVT_BUTTON($self, $btnID, \&auth_clicked); return $self; } sub auth_clicked { my $self = shift; $self->{panel}->Destroy; my $panel = Wx::Panel->new($self, -1); my $btnID = 66; $self->{btn} = Wx::Button->new($panel, $btnID, 'Restart', [50,50]); EVT_BUTTON($self, $btnID, \&newtran); } sub newtran { # return to start, place another transaction # doesn't work though. my $self = shift(); # the window handle print ref $self; $main::wxobj->Destroy; $main::wxobj->new; } ####################################### # # package MyApp; # # ####################################### use base qw(Wx::App); # Inherit from Wx::App sub OnInit # Every application has its own OnInit method that will # be called when the constructor is called. { my $self = shift; $frame = MainFrame->new(undef, # Parent window -1, # Window id 'Test App', # Title [1,1], # position X, Y [300, 400] # size X, Y ); $self->SetTopWindow($frame); # Define the toplevel window $frame->Show(1); # Show the frame } ########################################################### # # The main program # package main; use strict; use warnings; use vars qw/$wxobj/; $wxobj = MyApp->new(); # New HelloWorld application $wxobj->MainLoop;