Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: creating multiple widgets at runtime

by AReed (Pilgrim)
on Jul 25, 2005 at 04:00 UTC ( [id://477673]=note: print w/replies, xml ) Need Help??


in reply to creating multiple widgets at runtime

You should call MainLoop after the while loop, not within it. I'm pretty sure that MainLoop should only be called once within a given Tk program.

Replies are listed 'Best First'.
Re^2: creating multiple widgets at runtime
by pg (Canon) on Jul 25, 2005 at 04:49 UTC

    Just to clarify, this particular MainLoop should be removed not moved ;-)

Re^2: creating multiple widgets at runtime
by GrandFather (Saint) on Jul 25, 2005 at 05:12 UTC

    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.
      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://477673]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-23 17:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found