wxpython SplitterWindow panel 刷新后不能正确显示的问题?

现在用wxpython 做联系人应用, 希望实现点击左侧联系人列表刷新右侧联系人信息 现在使用了wx.SplitterWindow, ReplaceWindowwinOld, winNew 现在点击实现了替换,返回了True 。但是替换后不能在右侧显示。 SplitterWindow 部分代码:

class SplitterContactswx.SplitterWindow: def __init__self, parent, ID: wx.SplitterWindow.__init__self, parent, ID, style = wx.SP_LIVE_UPDATE self.sp = wx.SplitterWindowself self.InitSplitter def InitSplitterself: self.SetSize500, 500 style = wx.BORDER_SUNKEN with opencontacts.json, r as contacts: contacts = contacts.read contacts = json.loadscontacts contact = contacts.values[0] left_list = wx.Panelself, style=style left_list = ListContactsPanelself, style=style, contacts=contacts left_list.SetBackgroundColour"sky blue" right_list = ContactDetailself, style=style, contact=contact right_list.SetBackgroundColour"pink" self.SetMinimumPaneSize200 self.SplitVerticallyleft_list, right_list, -400

点击响应事件 处理

def OnColClickself, evt: i = evt.GetIndex contact = self.contacts.values[i] left = self.parent.GetWindow1 old = self.parent.GetWindow2 old.SetBackgroundColour"blue" style = wx.BORDER_SUNKEN new = ContactDetailself, style=style, contact=contact self.parent.ReplaceWindowold, new old.Destroy new.ShowTrue 

不知道哪里出了错误! 请教一下 谢谢!

终于发现哪里出现了问题

new = ContactDetailself, style=style, contact=contact
这一句应该是 new = ContactDetailself.parent, style=style, contact=contact

好尴尬

发表评论

电子邮件地址不会被公开。 必填项已用*标注