473,322 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Quick Question regarding Frames

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?

Thanks.

Chris

Mar 28 '06 #1
6 876
A little further clarification. FrameA and FrameB are in different
modules.

Thanks.

Chris

Mar 28 '06 #2
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

Mar 28 '06 #3
HI Dave,
Thanks for the reply.
I am a bit confused by this piece of code:
class FrameB(wx.Frame):
def __init__(self, frameA, ...):
self.frameA = frameA

What is frameA in the __init__ definition?
Do I need to create something called frameA in order to pass it to that
__init__ function?

Presently I would call FrameB as
w2 = FrameB(None, -1,"")
w2.Show()

Where would I put the reference to frameA?

Thanks.

Chris

Mar 28 '06 #4
Hi again. frameA in the __init__ is a parameter that is required to be
the FrameA object that is creating the FrameB. In my example, I was
assuming that the FrameB is created in a method of FrameA, so I created
it passing self as frameA:

w2 = FrameB(self, None, -1,"")
w2.Show()

--
Want to play tabletop RPGs over the internet?
Check out Koboldsoft RPZen: http://www.koboldsoft.com

Mar 29 '06 #5
Hi Dave,
Thanks for taking the time to reply to my posts. It really heped me
understand this better.

Thanks again.

Chris

Mar 29 '06 #6
I'm glad to have helped. Good luck with your project.

--
Want to play tabletop RPGs over the internet?
Check out Koboldsoft RPZen: http://www.koboldsoft.com

Mar 30 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.