[Tutor] tkinter, create widgets during runtime?

Karim karim.liateni at free.fr
Thu Jan 27 17:19:17 CET 2011


Hello Wayne,

I provided a complete example see the mail above, pretty similar to yours.

Regards
Karim

On 01/27/2011 04:54 PM, Wayne Werner wrote:
>
> On Wed, Jan 26, 2011 at 11:21 AM, Elwin Estle 
> <chrysalis_reborn at yahoo.com <mailto:chrysalis_reborn at yahoo.com>> wrote:
>
>     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
>
>     }
>
>
> for x in xrange(5):
>     Label(root, text="This is label %d" %x).pack()
>
> will generate the labels. You can't put the variable names in the 
> local namespace without some tricksy methods. You could, however, have 
> a dict labels and just do
>
> labels[x] = Label(root, text="blah")
> labels[x].pack()
>
> HTH,
> Wayne
>
>
> _______________________________________________
> 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/888eb180/attachment.html>


More information about the Tutor mailing list