How can I, in one panel that is in one frame, reference an input variable that is in another panel in another frame?
I basically want to create an 'Options' tab in the menubar of my wxpython gui, that when clicked on, opens a new frame that allows the user to change some variables. However, when I try to reference those variables later, I get AttributeError: type object 'OptionsPanel' has no attribute 'Input1'
I have both panels and both frames defined as classes. Here is my complete code:
import wx
class MainFrame(wx.Frame):
def __init__(self,title):
wx.Frame.__init__(self, None, title=title, pos=(150,150), size=(200,300))
menuBar = wx.MenuBar()
menu = wx.Menu()
m_options = menu.Append(wx.ID_EDIT, "&Options", "Options")
self.Bind(wx.EVT_MENU, self.OnOptions, m_options)
menuBar.Append(menu, "&Options")
self.SetMenuBar(menuBar)
panel=MainPanel(self)
def OnOptions(self, event):
frame = OptionsFrame("Options Frame")
frame.Show()
class OptionsFrame(wx.Frame):
def __init__(self,title):
wx.Frame.__init__(self, None, title=title, pos=(150,150), size=(200,200))
panel=OptionsPanel(self)
class OptionsPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.label = wx.StaticText(self, label="Input Value", pos=(40,60))
self.Input1 = wx.TextCtrl(self, value="1.0", pos=(80,80), size=(60,-1))
class MainPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.button =wx.Button(self, label="GO", pos=(60,100))
self.Bind(wx.EVT_BUTTON, self.OnClick,self.button)
def OnClick(self,event):
MyVariable= OptionsPanel.Input1.GetValue() #This won't work!
print dt0
if __name__=="__main__":
app = wx.App(redirect=False)
frame = MainFrame("Multiple Frames Attempt")
frame.Show()
app.MainLoop()
Thanks in advance!