Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One problem is that the OnClick method in class MainPanel is referencing the class OptionsPanel instead of referencing the instantiation of the class OptionsPanel ('panel') in class OptionsFrame.</p> <pre><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, "&amp;Options", "Options") self.Bind(wx.EVT_MENU, self.OnOptions, m_options) menuBar.Append(menu, "&amp;Options") self.SetMenuBar(menuBar) panel=MainPanel(self) self.options_frame = None def OnOptions(self, event): self.options_frame = OptionsFrame("Options Frame") self.options_frame.Show() def GetInput1Value(self): if self.options_frame is not None: return(self.options_frame.options_panel.Input1.GetValue()) else: return('None') class OptionsFrame(wx.Frame): def __init__(self,title): wx.Frame.__init__(self, None, title=title, pos=(150,150), size=(200,200)) self.options_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.parent_frame = 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= self.parent_frame.GetInput1Value() print MyVariable if __name__=="__main__": app = wx.App(redirect=False) frame = MainFrame("Multiple Frames Attempt") frame.Show() app.MainLoop() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload