我像这样初始化wx.ListBox
:
mylistbox = wx.ListBox(self, style=wx.LB_SINGLE)
mylistbox.Bind(wx.EVT_LISTBOX, self.OnEventListBox)
# some other things (append some items to the list)
mylistbox.SetSelection(5)
我还有:
^{pr2}$如何使初始化中的命令mylistbox.SetSelection(5)
紧跟着OnEventListBox
的调用?
备注:似乎SetSelection()
不会生成wx.EVT_列表框自动地。在
来自the documentation:
这是有目的的,这样在您尝试设置UI时不会触发所有事件。您只需手动调用
OnEventListBox
来获得所需的功能。在更好的是,如果您在init上执行的操作不需要事件,可以将初始化提取到一个单独的函数中,然后在init和
OnEventListBox
中调用该函数。在相关问题 更多 >
编程相关推荐