Implicit initialization is EVIL!

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Jul 7 21:58:42 EDT 2011


rantingrick wrote:

> So you prefer to close a gazillion windows one by one?

If I want to close all the windows, I can use the application's
"Quit" or "Exit" command, or whatever the platform calls it.

(Note that if there is a separate instance of the application
for each window -- as was suggested earlier -- then you don't
have that option, and you have to close them one by one
anyway.)

>>There's no way you could write Row and Column functions for
>>Tkinter that work like that -- they would have to take parent
>>widgets as arguments, and you wouldn't be able to nest the
>>calls.
> 
> WRONG! A function or class structure can handle this just fine.
> 
> class DumbDialog(tk.Toplevel):
>     def __init__(self, master, **kw):
>         w=tk.Label(master, text="Caution: Your underpants are on
> fire.")
>         w.pack()
>         w=tk.Button(master, text="OK").pack()
>         w=tk.Button(master, text="Cancel").pack()

Which is *exactly* what I said you would have to do in
Tkinter! Each widget creation requires a separate statement,
with the parent passed in at each step. This is nowhere
near as convenient as the nested function call style.

-- 
Greg



More information about the Python-list mailing list