Quick Question regarding Frames

Dave Mandelin mandelin at cs.berkeley.edu
Tue Mar 28 13:52:21 EST 2006


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




More information about the Python-list mailing list