in reply to Re: creating multiple widgets at runtime
in thread creating multiple widgets at runtime

Not alltogether true. The following is ok and can be usefull:

use strict; use warnings; use Tk; my $main = MainWindow->new (); $main->Button (-text => "Close", -command => sub{$main->destroy ();})- +>pack(); MainLoop; $main = MainWindow->new (); $main->Button (-text => "Close too", -command => sub{$main->destroy () +;})->pack(); MainLoop;

Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^3: creating multiple widgets at runtime
by mawe (Hermit) on Jul 25, 2005 at 05:46 UTC
    Hmm, how could this be useful? Can't you do the same with a Toplevel and only one MainLoop?

      In a context where you want to grab a chunk of information from the user a very light weight "open window, grab data, close window" is useful. In that context you don't want to go hunting for the $main that you may, or may not, have used before.

      I use this trick in apps that are essentially command line (or run from desktop short cuts) that sometimes need a little more info. It lets me write one utility that I can drag and drop onto, have snoop stuff out of the clipboard, or (if the other strategies fail) ask for the required info.


      Perl is Huffman encoded by design.