Quoting Danny Yoo <[EMAIL PROTECTED]>:

> I think that only widgets that are designated as "containers" can
> contain other widgets. A Frame is an example of a widget that can contain 
> other widgets:

This is (I think) true; but the root can also contain widgets, and it is the
default if no other master is specified.

For example:

>>> from Tkinter import *
>>> def foo():
...  print 'foo'
... 
>>> Button(text='foo', command=foo).pack()

This will produce a window with a button which, when clicked, will print 'foo'
to stdout.

To be honest, I'm a bit stumped by Adam's problem.  Here is some code I just
wrote which works perfectly (it produces a window with a column of buttons
labeled 'field 0' through 'field 9'; each button (when clicked) prints out its
number):

>>> from Tkinter import *
>>> def p(x):
...  print x
... 
>>> for i in xrange(10):
...  buttonName = 'field ' + str(i)
...  b = Button(text=buttonName, command=lambda i=i: p(i))
...  b.grid(row=i)
... 
>>>

-- 
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to