[wxPython] [Q] simple question

Hi, I have a simple question.

I was reading the wxPython document and I was stuck at the first example.

from wxPython.wx import wxPySimpleApp, wxFrame
app = wxPySimpleApp()
frame = wxFrame(None, -1, “Hello World”)
frame.Show(1)
app.MainLoop()

What is the relationship between app and frame? I don’t see any relationship between them in the above code.

Thanks.

YJ

[ please don't send html mail to this list ]

from wxPython.wx import wxPySimpleApp, wxFrame
    app = wxPySimpleApp()
    frame = wxFrame(None, -1, "Hello World")
    frame.Show(1)
    app.MainLoop()

What is the relationship between app and frame? I don't see any
relationship between them in the above code.

The frame is the thing you see onthe screen. The app provides system
initialization, the message retrieval and event dispatching loop. Without
the app the frame would get no events.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

Robin Dunn wrote:

> from wxPython.wx import wxPySimpleApp, wxFrame
> app = wxPySimpleApp()
> frame = wxFrame(None, -1, "Hello World")
> frame.Show(1)
> app.MainLoop()
>
> What is the relationship between app and frame? I don't see any
> relationship between them in the above code.

The frame is the thing you see onthe screen. The app provides system
initialization, the message retrieval and event dispatching loop. Without
the app the frame would get no events.

Also, when you pass None in as the parent of wxFrame (the first
argument), you are telling it that it is a top level frame, and therefor
the primary frame of the app.

-Chris

···

--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------

Also, when you pass None in as the parent of wxFrame (the first
argument), you are telling it that it is a top level frame, and therefor
the primary frame of the app.

Not quite true. Any frame/dialog with None for parent is a top level frame,
and an app can have more than one, so there really isn't a concept of a
primary frame anymore.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!