[Tutor] tkinter, create widgets during runtime?

Elwin Estle chrysalis_reborn at yahoo.com
Wed Jan 26 18:21:02 CET 2011


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?






      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110126/4599f9f9/attachment.html>


More information about the Tutor mailing list