Implicit initialization is EVIL!

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Jul 7 01:34:23 EDT 2011


rantingrick wrote:

> Yes but what benefit does that gain over say, Tkinter's design
> (because that has been your argument).

Like I said, it's a tangential issue.

The important thing is that it's okay for an app to stay
alive until its *last* top level window is closed. There
doesn't have to be a special "main" window that kills the
whole app when you close it.

However, I think what the original complaint was really
about is that when you create a non-toplevel widget in Tkinter
you have to specify its parent (and if you don't, it assumes
you want it to be a child of the main window). You can't
create the widget first and specify its parent later.

This is another API flaw that is seen distressingly often
in GUI libraries. It's a nuisance, because it means you can't
write code that creates a widget hierarchy bottom-up. For
example, in PyGUI you can write things like

   dialog_contents = Column([
     Label("Caution: Your underpants are on fire."),
     Row([Button("OK"), Button("Cancel")])
   ])

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.

-- 
Greg



More information about the Python-list mailing list