use Wx; package MainFrame; use base qw(Wx::Frame); use Wx qw(wxVERTICAL) use Wx::Event qw( EVT_BUTTON ); sub new { my $class = shift; my $self = $class->SUPER::new(@_); my $sizer = Wx::BoxSizer->new(wxVERTICAL); my $panel = Wx::Panel->new($self, -1); $panel->SetSizer($sizer); ## Auth Button my $authBtn = Wx::Button->new($panel, -1, "Authorize"); EVT_BUTTON($self, $authBtn->GetId, \&AuthHandler); $sizer->Add($authBtn); $self->{AuthBtn} = $authBtn; ## Restart Button my $restartBtn = Wx::Button->new($panel, -1, "Restart"); EVT_BUTTON($self, $restartBtn->GetId, \&RestartHandler); $sizer->Add($restartBtn); $self->{RestartBtn} = $restartBtn; ## Initial Layout $restartBtn->Show(0); $sizer->SetSizeHints($self); $self->Layout; return $self; } sub AuthHandler { my $self = shift; $self->{AuthBtn}->Show(0); $self->{RestartBtn}->Show(1); } sub RestartHandler { my $self = shift; $self->{AuthBtn}->Show(1); $self->{RestartBtn}->Show(0); } ########################## ## Main Application Class ########################## package MyApp; use base qw(Wx::App); sub OnInit { my $self = shift; $frame = MainFrame->new(undef, -1, 'Test App'); $self->SetTopWindow($frame); $frame->Show(1); } ###################### ## Run App ###################### package main; use strict; use warnings; my $app = MyApp->new; $app->MainLoop;