Reputation: 319
After I open my application, there would be a button that opens the second frame. so I want to tell my second frame to grab information based on a List that its value would be appended to by main frame.
For Example
In the main frame, there is self.pubID
and after I do an action I append a number to that list. after than I open the second frame but it doesn't grab that value that I appended, means it can't get the updated information from that list.
Thanks to you for your help. I know the code I gave looks awful but the whole script might be long and confusable to upload so I hope it shows something.
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
panel = wx.Panel(self, -1)
def OnSelect(self, event):
item = event.GetSelection()
del self.pubID[:]
self.pubID.append(item)
def onInsert(self, event):
self.Lin = InLink("Insert")
self.Lin.Show()
class InLink(wx.Frame):
def __init__(self,title):
wx.Frame.__init__(self, None, title=title, pos=(150,150), size=(200,200))
panel = wx.Panel(self)
Upvotes: 0
Views: 82
Reputation: 3113
If I understand correctly, InLink
needs to know what's inside MyFrame.pubID
. Well there's a simple solution to that problem: pass it to your constructor. So your InLink.__init__()
becomes this:
class InLink(wx.Frame):
def __init__(self,title, pubID):
#now you can easily get the value from pubID
...
However, I think you have some problems in their code beyond just that. I posted a comment asking you to explain in more detail what you wanted to do. From reading your question I think you want InLink
to return some value that that MyFrame
will use. Is this correct? If so, instead of using a wx.Frame
you should be using a wx.Dialog
. Here is a previous SO post about wx.Dialog
s. That answer contains links to other tutorials to help you get started.
Upvotes: 1