[Tutor] tkinter, create widgets during runtime?

Elwin Estle chrysalis_reborn at yahoo.com
Thu Jan 27 13:15:37 CET 2011


>From the lack of replies...I am guessing that this can't be done.  Tho I just realized I had a typo in part of it.

The line that reads:
"Is there a way to do something like this in Tkinter?  Or am I correct in
 guessing that if it is not possible, it is probably more complicated 
than the above?"

...should have said, "Or am I correct in guessing tat if it IS possible, it is probably more..."

--- On Wed, 1/26/11, Elwin Estle <chrysalis_reborn at yahoo.com> wrote:

From: Elwin Estle <chrysalis_reborn at yahoo.com>
Subject: [Tutor] tkinter, create widgets during runtime?
To: tutor at python.org
Date: Wednesday, January 26, 2011, 12:21 PM

With Tcl/Tk, you can generate widgets "on the fly" during program execution, without having to explicitly create them in your code.  i.e., something like:

for {set i 0} {$i <= 5} {incr i} {
    label .myLabel_$i -text "this is label myLabel_$i"
    pack .myLabel_$i
}

...which will generate five labels from "myLabel_0" to "myLabel_5".

Useful if you need a varying number of widgets, or a series of "incremental" widgets.

Is there a way to do something like this in Tkinter?  Or am I correct in guessing that if it is not possible, it is probably more complicated than the above?






      
-----Inline Attachment Follows-----

_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110127/3bd2cab6/attachment.html>


More information about the Tutor mailing list