in reply to help me speed up badly designed perltk code?
As to giving you some clues, based on guessing what you want, there is the toplevel window, for creating and removing windows quickly.
#!/usr/bin/perl + use Tk; + $mw = MainWindow->new; + $mw->title("MainWindow"); + $mw->Button(-text => "Toplevel", -command => \&do_Toplevel)->pack( ); + + MainLoop; + sub do_Toplevel { + if (! Exists($tl)) { + $tl = $mw->Toplevel( ); + $tl->title("Toplevel"); + $tl->Button(-text => "Close", + -command => sub { $tl->withdraw })->pack; + } else { + $tl->deiconify( ); + $tl->raise( ); + } + }
|
|---|