frame communication

Hello,

I am new to wxPython and I have a question that I have been unable to find the answer to while reading the demo code or searching the mail lists. I apologize if it has been asked and answered before. I do have the “wxPyton in Action” on order. :slight_smile:

My GUI consists of a main window that has several buttons on it. Each button will open a new window that does its own thing, such as display telemetry data, or control the speed of a camera, etc. I would like the main GUI to know when the other windows have closed, so it can change the button state appropriately. I was wondering if someone can point me to a document that may describe how to accomplish this.

It could be that I am going about this the wrong way. Currently, I do something as follows to draw the new window:

button event calls WfsCam

def WfsCam (self, event):

print “Starting WFS Cam…”

self.wfs = wfscam.WFSCam (self, 125, ‘WFS Camera’)

self.wfs.Show (True)

Any advise is greatly appreciated!

Thanks,

Steve

Steve G escribió:

My GUI consists of a main window that has several buttons on it. Each button will open a new window that does its own thing, such as display telemetry data, or control the speed of a camera, etc. I would like the main GUI to know when the other windows have closed, so it can change the button state appropriately. I was wondering if someone can point me to a document that may describe how to accomplish this.

Hello Steve,

You can do it calling self.GetParent().method_before_closing() from the child window. Or maybe I didn't understand the question. :slight_smile:

Regards
Marcelo

···

--
Marcelo F. Fernández
Buenos Aires, Argentina
Licenciado en Sistemas - CCNA

E-Mail: fernandezm22@yahoo.com.ar
Jabber ID: fernandezm22@jabber.org
Public Key ID: 5C990A6C 111C3661
Blog: http://marcelosoft.blogspot.com

Steve G wrote:

Hello,

I am new to wxPython and I have a question that I have been unable to find the answer to while reading the demo code or searching the mail lists. I apologize if it has been asked and answered before. I do have the "wxPyton in Action" on order. :slight_smile:

My GUI consists of a main window that has several buttons on it. Each button will open a new window that does its own thing, such as display telemetry data, or control the speed of a camera, etc. I would like the main GUI to know when the other windows have closed, so it can change the button state appropriately. I was wondering if someone can point me to a document that may describe how to accomplish this.

It could be that I am going about this the wrong way. Currently, I do something as follows to draw the new window:

button event calls WfsCam

def WfsCam (self, event): print "Starting WFS Cam..."
        self.wfs = wfscam.WFSCam (self, 125, 'WFS Camera')
        self.wfs.Show (True)

Any advise is greatly appreciated!

Thanks,

Steve

I use pubsub for this sort of thing. It allows me to send messages to any listener or listeners. Anyway, check out the following links for additional details:

http://wiki.wxpython.org/PubSub
http://www.wxpython.org/docs/api/wx.lib.pubsub-module.html
http://wiki.wxpython.org/Controlling%20GUI%20with%20pubsub

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

Or you can bind to the wx.EVT_CLOSE event:

     self.wfs.Bind(wx.EVT_CLOSE,
                   self.OnWfsFrameClose,
                   self.wfs)

Then your OnWfsFrameClose method will be called when the window is
closed.

This page has some guidelines for EVT_CLOSE handlers:

http://docs.wxwidgets.org/2.8/wx_wxcloseevent.html#wxcloseevent

Hope that helps,

Simon

···

-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org
[mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf
Of Mike Driscoll
Sent: 03 March 2009 14:53
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] frame communication

Steve G wrote:
> Hello,
>
> I am new to wxPython and I have a question that I have been
unable to
> find the answer to while reading the demo code or searching
the mail
> lists. I apologize if it has been asked and answered
before. I do have
> the "wxPyton in Action" on order. :slight_smile:
>
> My GUI consists of a main window that has several buttons
on it. Each
> button will open a new window that does its own thing, such
as display
> telemetry data, or control the speed of a camera, etc. I would like
> the main GUI to know when the other windows have closed, so it can
> change the button state appropriately. I was wondering if
someone can
> point me to a document that may describe how to accomplish this.
>
> It could be that I am going about this the wrong way.
Currently, I do
> something as follows to draw the new window:
>
> button event calls WfsCam
>
> def WfsCam (self, event):
> print "Starting WFS Cam..."
> self.wfs = wfscam.WFSCam (self, 125, 'WFS Camera')
> self.wfs.Show (True)
>
> Any advise is greatly appreciated!
>
> Thanks,
>
> Steve

I use pubsub for this sort of thing. It allows me to send messages to
any listener or listeners. Anyway, check out the following links for
additional details:

http://wiki.wxpython.org/PubSub
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
Controlling GUI with pubsub - wxPyWiki

King Simon-NFHD78 wrote:

···

-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org [mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf Of Mike Driscoll
Sent: 03 March 2009 14:53
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] frame communication

Steve G wrote:
    

Hello,

I am new to wxPython and I have a question that I have been
      

unable to
    

find the answer to while reading the demo code or searching
      

the mail
    

lists. I apologize if it has been asked and answered
      

before. I do have
    

the "wxPyton in Action" on order. :slight_smile:

My GUI consists of a main window that has several buttons
      

on it. Each
    

button will open a new window that does its own thing, such
      

as display
    

telemetry data, or control the speed of a camera, etc. I would like the main GUI to know when the other windows have closed, so it can change the button state appropriately. I was wondering if
      

someone can
    

point me to a document that may describe how to accomplish this.

It could be that I am going about this the wrong way.
      

Currently, I do
    

something as follows to draw the new window:

button event calls WfsCam

def WfsCam (self, event): print "Starting WFS Cam..."
        self.wfs = wfscam.WFSCam (self, 125, 'WFS Camera')
        self.wfs.Show (True)

Any advise is greatly appreciated!

Thanks,

Steve
      

I use pubsub for this sort of thing. It allows me to send messages to any listener or listeners. Anyway, check out the following links for additional details:

http://wiki.wxpython.org/PubSub
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
Controlling GUI with pubsub - wxPyWiki

Or you can bind to the wx.EVT_CLOSE event:

     self.wfs.Bind(wx.EVT_CLOSE,
                   self.OnWfsFrameClose,
                   self.wfs)

Then your OnWfsFrameClose method will be called when the window is
closed.

This page has some guidelines for EVT_CLOSE handlers:

wxCloseEvent

Hope that helps,

Simon

I've done that before as well. Whichever makes the most sense in your case is what you should go with.

Mike