[newbie] Connection between app and frame?

Hello

  I'm reading "wxPython in Action", and am puzzled at the lack of
connection between an app and a frame:

if __name__ == '__main__':
  app = wx.PySimpleApp()
  frame = StaticTextFrame()
  frame.Show()
  app.MainLoop()

How can the app and the frame communicate, since there doesn't seem to
be a connection in the above code?

Thank you.

The connection is in MainLoop().

···

2008/4/3, Gilles gilles.ganault@free.fr:

Hello

    I'm reading "wxPython in Action", and am puzzled at the lack of

connection between an app and a frame:

if name == ‘main’:
app = wx.PySimpleApp()

    frame = StaticTextFrame()
    frame.Show()
    app.MainLoop()

How can the app and the frame communicate, since there doesn’t seem to
be a connection in the above code?

Thank you.


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

But since I can call the frame class and instance whatever I like, how
does app knows about frame?

···

On Thu, 3 Apr 2008 07:09:42 +0200, "Raffaello Barella" <barbarossa.platz@gmail.com> wrote:

if __name__ == '__main__':

        app = wx.PySimpleApp()
        frame = StaticTextFrame()
        frame.Show()
        app.MainLoop()

The connection is in MainLoop().

When you create a the first wx.Frame, this frame becomes the TopWindow.
You can get this frame using app.GetTopWindow()

Peter

···

On Thu, Apr 3, 2008 at 5:55 PM, Gilles gilles.ganault@free.fr wrote:

On Thu, 3 Apr 2008 07:09:42 +0200, “Raffaello Barella” > > barbarossa.platz@gmail.com wrote:

if name == ‘main’:

    app = wx.PySimpleApp()
    frame = StaticTextFrame()
    frame.Show()
    app.MainLoop()

The connection is in MainLoop().

But since I can call the frame class and instance whatever I like, how

does app knows about frame?


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


There is NO FATE, we are the creators.

This argument seems mere ‘lana caprina’.
Whatever the name we limited human beings give to an object (frame or anything else), any programming language assigns to it at the first occurrence an unique number (usually an integer or a long) and thereinafter always refers to it by that number. Try using GetId() at the first occurrence of your frame, then change its name with SetName() and use again GetI(): the result will be the same.
By the way, wx.Object who is the base class of wx.Window and wx.Frame, but is not normally used directly by us laymen, does NOT have an attribute SetName().

···

2008/4/3, Peter Damoc pdamoc@gmail.com:

When you create a the first wx.Frame, this frame becomes the TopWindow.
You can get this frame using app.GetTopWindow()

Peter

On Thu, Apr 3, 2008 at 5:55 PM, Gilles gilles.ganault@free.fr wrote:

On Thu, 3 Apr 2008 07:09:42 +0200, “Raffaello Barella” > > > > barbarossa.platz@gmail.com wrote:

if name == ‘main’:

    app = wx.PySimpleApp()
    frame = StaticTextFrame()
    frame.Show()
    app.MainLoop()

The connection is in MainLoop().

But since I can call the frame class and instance whatever I like, how

does app knows about frame?


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


There is NO FATE, we are the creators.


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

As you've seen from the messages here, there are lots of ways, but my
earlier suggestion:

Sorry, I wasn't clear: I don't want to link the two. I'd like to
understand how the two know about each other, since I don't see any
instruction that somehow links the app and the frame, hence how does
the app know that the frame was closed, and it should terminate the
application?

The demo code form the book you're looking at is simplified to the
easiest way to get an app up.

OK, so it doesn't really matter. The fuller code below does link the
two and makes sense to a newbie like me:

class MyApp(wx.App):
    def OnInit(self):
        self.frame = MyFrame(None, -1)
        self.SetTopWindow(self.frame)
        self.frame.Show()
        return True

Thanks guys.

···

On Thu, 03 Apr 2008 10:12:16 -0700, Christopher Barker <Chris.Barker@noaa.gov> wrote: