Implicit initialization is EVIL!

Chris Angelico rosuav at
Thu Jul 7 14:24:12 EDT 2011

On Fri, Jul 8, 2011 at 3:29 AM, rantingrick <rantingrick at> wrote:
> So your argument is:
>    """ A window hierarchy is bad because if your application requires
> a user to open a gazillion windows (read as: designed poorly) --each
> representing completely different transactions-- and if you close the
> original window all the "other" windows will close too. Boo :("""

Why should opening multiple windows AUTOMATICALLY equate to poor design?

> So you prefer to close a gazillion windows one by one? If so, why not
> just code the GUI correctly from the start; by creating separate
> transactions? Thereby reducing the number of windows a user must
> juggle? FYI: You know the user complexity of a GUI increases
> exponentially by the number of windows present.

By "separate transactions" do you mean that the user can
simultaneously perform multiple actions? Because that's best done with
multiple separate interfaces - such as, multiple windows. Or do you
really mean "sequential transactions"? That would not in any way be
good design.

>> For
>> example, in PyGUI you can write things like
>>    dialog_contents = Column([
>>      Label("Caution: Your underpants are on fire."),
>>      Row([Button("OK"), Button("Cancel")])
>>    ])
> WRONG! A function or class structure can handle this just fine. And
> lends itself nicely to GUI programming.

You have to break your code into two pieces. Here's an alternative way
of laying out a dialog, this taken from Pike-GTK2:


This program uses utility functions such as:

//Helper function to create a button and give it an event. Useful
because signal_connect doesn't return self.
GTK2.Button button(mixed content,function clickevent,mixed|void arg)
        GTK2.Button ret=GTK2.Button(content);
        return ret;

I make no apologies for the braces in the code :)

The 'button' function creates a button and assigns it an event. At
this stage, the button has no parent; it won't be drawn anywhere. The
GTK2.Button object is returned, and then added. It's added to the
HbuttonBox which is then added to the Vbox which is only then added to
the main window; although the code would work just fine if done in the
other order. It's important here that objects are simply objects -
they don't have to be built in a tree structure; and the window's
layout is entirely in the one place, I don't have to put half of it
into the window's constructor.


More information about the Python-list mailing list