[Tutor] SetTopWindow

Alan Gauld alan.gauld at btinternet.com
Thu May 20 01:19:52 CEST 2010


"Gary Koskenmaki" <garywk at cableone.net> wrote
>I have what is a noob's confusion about this that will lead to bigger
> problems for me later on if I don't clear it up.

Don't worry, this kind of confusion abounds in GUI toolkits of all
kinds not just wxPython.

> In wxPython what a user normally refers to as a "window" is known as 
> a
> frame.  And what is known in wxPython as a window is an object such 
> as a
> TextCtrl object.  At least that is what I take from "wxPython in
> Action".

Correct, and the latter usage is common parlance in most GUI 
frameworks.
A window is any visible area of the screen, including widgets. The 
name
for the top level object varies from toolkit to toolkit.

> Now, wxApp has a method called SetTopWindow and you normally pass 
> your
> wxframe object to it so that it knows what is to be top object.

I think this is historic since many early toolkits had some kind of
setTopWindow method (Microsoft and Borland, and at least one X windows
toolkit all did). The name in wxPython is simply a reflection of the 
underlying
C++ wxWidgets which, I think, simply reflects the historical legacy.

> Why isn't it named something like SetTopFrame?
> What am I missing?

Nothing, it's just one of the many accidents of programming legacy.
Like why does Lisp use "car" to get the first item off a list? Because
that's the machine instruction that did it on the computer they built
the first Lisp on... There are a lot of these historical accidents 
that
creep into programming languages. Learn to love them! :-)

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list