python - How to open up a new child window when a button is clicked? (wxpython) -


How do you open hair frames when a button is clicked on the main window? The code below creates a drop down box. My problem is that I have a separate class for the main window and how do I open this new drop down box window in my main application? There is only one wx.frame in the main window, where the button is added.

  import wx class myframe (wx.frame): def __init __ (self): wx.frame .__ init __ (own, none, -1, 'wxChoice test', Size = (300, 150)) colorList = ['blue', 'green', 'yellow', 'red'] # dropdown box builds itself. Keys 1 = wx.Choice (self, -1, option = color list) # Select the item 1 = 'green' to show itself. Top 1 .Set selection (1) # Optional keyboard input for #P, type R for Y, R for y. Choice 1.SetFocus () #New event handler wxPython version 2.5 and higher self.choice1.bind (wx.EVT_CHOICE, self. Chains) def onChoice (self, event): 'Get' option selected color option '' 'Self. Kolor = Self. Choice 1 GetString (Self crawler) # Test # This is just a small application application wx.PySimpleApp () # Call Class MyFrame frame1 = MyFrame) # Show frame frame 1 Show True (True) # Event Loop App Main Loop ()    

The simplest example I can import wx in a few minutes

  def show_other (evt): f2 = wx.frame (none, -1) c = wx.Choice (f2, -1, option = ['red', 'blue', 'green' ']) F2.Show () a = wx.App (redirect = False) f = wx.Frame (none, -1) B = wx.Button (F, wx.ID_OK) b.Bind (wx.EVT_BUTTON, Show_other) f.Show () a.MainLoop ()    

Comments