Tkinter Question

Fredrik Lundh fredrik at pythonware.com
Wed Jun 15 12:54:07 EDT 2005


Nicholas.Vaidyanathan at aps.com wrote:

> Thanks for all the help guys... I'm a bit confused as to the inner
> workings of the Tkinter system (I'm both a Python and a GUI n00b). I was
> hoping that by slapping the x on button python was doing some cool
> dynamic variable creation (i.e. creating 9 variables with 1 loop using
> the x as a variable to modify the identifier), but I suppose you can't
> do that in Python (or can you?)

that's what lists are for (see the python tutorial for details).

> I'm a little confused as to why self.button.text doesn't work but
> self.button["text"] does, can someone explain this?

x.text and x["text"] are two different operations in Python, and
Tkinter uses the former for widget methods, and latter for widget
options.

(w[x] is a shortcut for x.cget(x), btw)

</F>






More information about the Python-list mailing list