Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Basically my problem is that I want to call a sub which opens a new GUI window and then destroys the current one so there is only one window open. I'll write out an example of a package and stick in a comment " $mw => 'destroy' " where I want it to happen. I don't know if this problem is trivial or not since everything I have tried hasn't worked but I'm open to suggestions (ps: i looked at perls wizard package but i didn't understand it much, but i'm sure there is a way to do this without using it.)
Here's the code:
PS: It also doesn't add the image if I add this code in the sub although if the code is outside a sub it seems to work fine, any ideas?package example; use vars qw(@ISA @EXPORT @EXPORT_OK); use Exporter; @ISA = qw(Exporter); # Symbols to autoexport (:DEFAULT tag) @EXPORT = qw( ex1 ex2 %program_config ); use vars qw(%program_config); use Tk; sub ex1(){ my $mw = MainWindow->new; $mw->title("example_window1"); $mw->MainWindow->Frame( -relief=>'groove'); $mw->minsize(600,300); my $bf = $mw-> Frame( -pady => '5') ->pack( -side => 'bottom', -anchor=>'se'); my $cancel = $bf -> Button( -relief=> 'raised', -borderwidth => '2', -text => "Cancel", -command => [$mw => 'destroy']) ->pack( -side => 'right', -padx => '20'); my $next = $bf -> Button( -relief=> 'raised', -borderwidth => '2', -text => "Next", -command => sub {ex2();}, # This is where i want it to kill the window (after the #other sub has been called) # $mw => 'destroy'] ) ->pack( -side => 'right'); my $back = $bf -> Button( -relief=> 'raised', -borderwidth => '2', -text => "Back") ->pack( -side => 'right'); MainLoop; } sub ex2(){ my $mw = MainWindow->new; $mw->title("example_window2"); $mw->MainWindow->Frame( -relief=>'groove'); $mw->minsize(600,300); my $msg = $mw -> Message(-text => "Just an example")->pack(); my $bf = $mw-> Frame( -pady => '5') ->pack( -side => 'bottom', -anchor=>'se'); my $finish = $bf -> Button( -relief=> 'raised', -borderwidth => '2', -text => "Finish", -command => [$mw => 'destroy']) ->pack( -side => 'right', -padx => '20'); MainLoop; }
Thanks a million everyone for your help, it is much appreciated and sorry for the long post.my $image = $mw->Photo( -file => "saraLogo2.gif"); $mw->Label( -image => 'image1') ->pack( -side=> "left", -anchor => 'n');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: window destroying
by moot (Chaplain) on Mar 28, 2005 at 17:43 UTC | |
by Anonymous Monk on Mar 28, 2005 at 18:21 UTC | |
|
Re: window destroying
by zentara (Cardinal) on Mar 28, 2005 at 20:09 UTC |