[Tutor] Tkinter

David Rock david at graniteweb.com
Thu Apr 29 16:20:10 EDT 2004


* Olavi Ivask <olavi at city.ee> [2004-04-29 23:14]:
> David Rock wrote:
> >
> >label = Label(root, text="Label1").grid()
> >
> >assigns the grid object to the variable label, while 
> >
> >label = Label(root, text="Label1")
> >
> >assigns the LABEL object to label. The second one is probably better
> >because you are working with the primary object that you can call ALL
> >methods for, not just grid(), while the first is limited to JUST grid()
> > 
> >
> can i do something like that:
> I "define" several widgets:
>    label = Label(root, text="text")
>    label = Label(root, text="text2")
>    ...
>    label.grid()
> 
>    right now, it shows only second widget.

No. you are overwriting the first assignment with the second. You would
have to use label1, label2, etc. Ideally, label would be something
vaguely descriptive so you could tell at a glance _which_ label it is
and what it's for.

-- 
David Rock
david at graniteweb.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20040429/676e8ac4/attachment.bin


More information about the Tutor mailing list