Implicit initialization is EVIL!
rantingrick at gmail.com
Mon Jul 4 13:09:25 EDT 2011
On Jul 4, 11:01 am, Chris Angelico <ros... at gmail.com> wrote:
> On Tue, Jul 5, 2011 at 1:46 AM, rantingrick <rantingr... at gmail.com> wrote:
> > On Jul 4, 10:40 am, Chris Angelico <ros... at gmail.com> wrote:
> >> Uhh, sorry. No. There are plenty of good reasons for one application
> >> to make multiple top-level windows, and if I ever find myself using a
> >> toolkit that makes this difficult, I'll either be hacking the toolkit
> >> or using a different one. I've been building GUI applications for far
> >> too long to not want features like that.
> > And those reasons are...?
> As varied as the applications that call on them. One example that
> springs to mind: Our database front end has "table view" and "record
> view", where you get one table view and from that you can view as many
> records as you like. Users may choose to effectively switch from one
> view to the other, or they may open up two or more record views and
> have them and the table view all on screen simultaneously.
> This is not
> a modal dialog; it's not even a modeless dialog - it's a completely
> stand-alone window that can be moved around the Z order independently
> of the parent.
You can do the exact same thing with Tkinter's windows.
> There's a definite ownership based on process, though;
> terminate the process (by closing the table view) and it must close
> all record views first. I've done other applications where this has
> not been the case - where all top-level windows are truly equal - but
> not in this instance.
Tkinters Toplevels ARE equal!
However in this case you should spawn a new instance of the
application "opened" at that particular table view. It's as simple as
a few command line arguments in your script.
It's like a text editor, you never want a "New" command that resets
the current document or an open command that resets the current
document and loads the file into the existing editor. Each application
instance should only create one document and stick with it until it is
Instead you want to spawn a new instance of the editor and tell the
editor (via command line arguments) to load file data (if applicable).
Simple command line arguments (of which you should be using anyway)
are the key here. All part of proper software design.
More information about the Python-list