Re: Quick Question regarding Frames
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Quick Question regarding Frames

From: Dave Mandelin <mandelin@cs.berkeley.edu>
Date: Tue Mar 28 2006 - 20:52:21 CEST

Chris S wrote:
> Hello All,
> Just starting out with Python and wxPython. I have two Frames, FrameA
> and FrameB. FrameA opens FrameB when a button on FrameA is clicked. I
> can get this. Now I want a button on FrameB to update a control on
> FrameA. I am having an issue with this. Can anyone point me in the
> right direction?

I'm sure there are many ways of doing it, but I have always done it by
giving FrameB a reference to FrameA. Something like:

class FrameA(wx.Frame):
    ...
    def OnSomethingClicked(self, event):
        f = FrameB(self, ...)
        f.Show()
        event.Skip()

    # This function does the updating of the control, to make things
    # easier to maintain than having FrameB manipulate controls
    # of FrameA directly.
    def UpdateSomeControl(self, ...):
        ...

class FrameB(wx.Frame):
    def __init__(self, frameA, ...):
        self.frameA = frameA

    def OnOtherThingClicked(self, event):
        self.frameA.UpdateSomeControl(...)

--
Want to play tabletop RPGs over the internet?
    Check out Koboldsoft RPZen:    http://www.koboldsoft.com
Received on Sun Apr 30 21:27:06 2006