[Tutor] Tkinter
Alan Gauld
alan.gauld at blueyonder.co.uk
Sun Mar 7 14:04:35 EST 2004
> I'm a bit confused about the top-level processing in Tkinter.
>
> 2 of my books start with tk=Tk() and build inside tk.
THis is normal wisdom when working with TRk - you create a top
level widget which forms the paremt of all others and
traditionally call it tk (or sometimes top).
> 1 book starts with o = MyClass() where MyClass(Frame) and
> builds inside itself.
This is because Tk (the underlying toolkit) takes an object
based approach to widgets whereas Tkinter is a wholly object
oriented version. But Tkinter allows you to use either form
of GUI building style - either procedural using objects or OOP.
The MyClass(Frame) style is using takes the pure OOP approach.
> But when I self.destoy() a frame gets left behind.
I suspect that's because you aren't passing the parent onto
MyClass constructor?
tk = Tk()
app = MyClass(tk)
So when you destroy the MyClass instance the Tk() window
remains? But thats a guess...
> Then I read that there's a toplevel widget. What's Tk()?
Its the top level widget! :-)
HTH,
Alan G.
More information about the Tutor
mailing list