python - wxpython widgets within not responding to events -


I am a newbie in wxpython and am trying to put some widgets to me in books (bookbook, notebook, favorite book).

Often ended up with some widgets placed inside containers not responding to incidents. I'm not sure what I'm doing wrong below is one of my codes

  import wx square ChoicePanelTwo (wx.Panel): def __init __ (self, guardian, seed): wx.Panel .__ init __ (self, parent = parent, id = Wx.ID_ANY) self Bakgroundcolr ( 'blue') sizer = wx.boxSizer (wx.HORIZONTAL) self.List = wx.ListCtrl (self - 1, style = wx.LC_REPORT) for the category (in seed): itself .List.InsertStringItem (i, str (i)) sizer.Add (self.List, 1, wx.ALL | wx.EXPAND, 5) Self.SetSizer (sizer) class ChoicePanelOne (wx.Panel): def __init __ (self, parent, seed): wx.panel.__init __ (self, mum Ita = parent, id = wx.ID_ANY) self.SetBackgroundColour ( 'green') sizer = wx.BoxSizer (wx.HORIZONTAL) self.RegisterList = wx.Choicebook (self, wx.ID_ANY) sizer.Add (self. RegisterList, 1, wx.ALL | wx.EXPAND, 5) For the range (seeds): self Registrar List.Apages (ChoicePanelTwo (Self, Seed * 50), str (I)) Self. Setser Class Tree Panel (wx.Panel): def __init __ (self, guardian, seed): wx.panel.__ Init __ (self, parent, id = wx.ID_ANY) self.SetBackgroundColour ('cyan') in the category for self.Choicbook = wx.Choicebook (self, wx.ID_A NY): self Choicbook.AddPage (ChoicePanelOne (Self, Seed * 2), str (i) sizer = wx.BoxSizer (wx.VERTICAL) sizer.Add (self.Choicbook, 1, Wx.ALL | wx.EXPAND, 5) self. SetSizer class AppFrame (wx.Frame): "" "application main frame" "title" 'application' WindowSize = (1024, 768) seeds = 2 def __init __ (self): wx.frame .__ init __ (self, no, -1, self.title, size = self.WindowSize, style = wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx. CLIP_CHILDREN) self.create_main_panel () def Create_main_panel (self ): Self.panel = TreePanel (self, self.seed) if __name__ == '__main__': app = wx.PySimpleApp () app.frame = AppFrame () app.frame .how () app.MainLoop ()   

In this example. What does the book and the list seem to be doing that I am doing wrong?

This is a parenting issue when you should be a ChoicBook, then you have all the ChoicePanelOne example parents Are setting up TreePanel and you are doing the same thing in ChoicePoint, where you create a complete group of ChoicePanellet, whose parents are ChoicePanel when they should be registered. See a little modified code:

  import wx square ChoicePanelTwo (wx.Panel): def __init __ (self, guardian, seed): wx.panel.__ init __ (self, mother Father = parent, id = wx.ID_ANY) self.SetBackgroundColour ('blue') sizer = wx.boxSizer (wx.HORIZONTAL) self.List = wx.ListCtrl (self, -1, style = wx.LC_REPORT) Category I (seed) in: self List.instestusting item (i, str (i) sizer.Add (self.List, 1, wx.ALL | wx.EXPAND, 5) self.SetSizer (sizer) class ChoicePanelOne (wx.Panel): def __init__ (self , Parent, seed): wx.panel.__ init __ (self, parent = parent, id = wx.ID_ANY) self.SetBackgroundColour ('green') size scale = wx.boxoxizer (wx.HORIZONTAL) self. RegisterList = wx. Choicebook (self, wx.ID_ANY) sizer.Add (self.RegisterList, 1, wx.ALL | 5 wx.EXPAND,) in the range of I (seeds): self.RegisterList.AddPage (ChoicePanelTwo (self.RegisterList, seeds * 50), Straw (I)) Self .Set class (wx.Panel): def __init __ (self, guardian, seed): wx.panel.__ init __ (self, parent, id = wx .ID_ANY) self SetBackgroundColour ('cyan') self Chekobo OK = wx.Choicebook (self, wx.ID_ANY) in category (ii): self Choicbook.AddPage (ChoicePanelOne (AutoCheckbook, Seed * 2), str (i) sizer = wx.BoxSizer (wx. VERTICAL) sizer.Add (self.Choicbook, 1, wx.ALL | wx.EXPAND, 5) Self.SetSizer class AppFrame (wx.Frame): "" "main frame of application" "title = 'application' windowSys = (1024, 768) seeds = 2 def __init __ (self): wx.Frame. __ init __ (self, no, 1, save. Tetl, size = Atmkvindo size, style = wx.MINIMIZE_BOX | wx. SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN) self.create_main_panel () def create_main_panel (self): self.panel = TreePanel (self, self.seed) If __name__ == '__main__': app = wx.PySimpleApp () App.frame = AppFrame () app.frame.Show () app.MainLoop ()   

You should download the wxPython demo because it has very good examples in it

You can also use it to help you diagnose the problem and this will tell you Where and how your parents have been kept with your soldiers.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -