Greetings fellow acolytes

I have recently started working with Wx as a generic yet more platform native toolkit than Tk and have hit a snag. I'm writing a small data entry application which is basically 2 screens. Screen 1, enter some data & click a save button, then screen 2 comes up with a confirmation message & button to get a new clean starting screen. Thats the theory. In practice, I can get up to the confirmation screen OK & wipe it but I can't redisplay the initial screen widgets.

The code I have (trimmed down & simplified as far as possible) is

#!/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_CHI +LDREN); 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;

just another cpan module author

In reply to Clearing & Redrawing a Wx Window by spatterson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.