[Tutor] Re: Tkinter
Marilyn Davis
marilyn at deliberate.com
Mon Mar 8 13:53:12 EST 2004
Thank you Michael and Alan.
I'm getting clearer. "Container and containee"! Of course.
And yes, the destroy method does call __del__. That's a relief.
I'm liking this form:
----------------
#!/usr/bin/env python
'''Hello World in a GUI using Tkinter'''
from Tkinter import *
class Hello(Tk):
def __init__(self):
Tk.__init__(self)
self.title('Hello World')
if __name__ == '__main__':
Hello().mainloop()
------------------
Is this acceptible?
I'm confused about pack() and grid(). I understand that you
shouldn't pack and grid into the same container. But can I
not grid into a container that is packed into its container?
I'm surprised that the following doesn't work. The Label in
the Frame at the bottom doesn't show up.
Are constrained to use the same geometry manager throughout an
application? Or am I making some other mistake?
--------
#!/usr/bin/python
from Tkinter import *
class Hello(Tk):
def __init__(self):
Tk.__init__(self)
self.title("Hello World")
self.geometry("150x100") #width x height
Label(self, text="Hello World").pack(side=LEFT)
b = Button(self, text="Bye", command=self.destroy)
b.pack(side=RIGHT)
f = Frame(self)
f.pack()
Label(f, text='Frame').grid()
if __name__ == '__main__':
Hello().mainloop()
--------
Thank you again for the valuable help.
Marilyn Davis
More information about the Tutor
mailing list