将 ListCtrl 对象切换到另一个对象
在 wxPython 中,如果我有一个框架,并且其中有一个带有 ListCtrl 对象的 sizer;我可以将此 listctrl 对象切换到另一个对象的最简单方法是什么。
???
self.list = wx.ListCtrl(panel, size=(-1, 530), style=wx.LC_REPORT|wx.BORDER_SUNKEN|wx.LC_HRULES )
self.list.InsertColumn(0, 'Country' , width = 140)
self.list.InsertColumn(1, 'Consumption', width = 115)
sizer.Add(self.list, 0, wx.ALL|wx.EXPAND, 5)
我可以将 sizer 中的这个 listctrl 对象更改为另一个对象吗
In wxPython, If I have a frame and in it I have a sizer with a ListCtrl object; what is the easiest way that I can switch this listctrl object to another one.
example-code
self.list = wx.ListCtrl(panel, size=(-1, 530), style=wx.LC_REPORT|wx.BORDER_SUNKEN|wx.LC_HRULES )
self.list.InsertColumn(0, 'Country' , width = 140)
self.list.InsertColumn(1, 'Consumption', width = 115)
sizer.Add(self.list, 0, wx.ALL|wx.EXPAND, 5)
Can I change this listctrl object in sizer to another one???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太确定你想做什么,但我会猜测一下,你的 gui 中有两个 ListCtrl,并且你希望能够在它们之间切换?
如果是这样,我想我的第一个建议是仅重用单个 ListCtrl 来实现这两个目的,当您可以简单地刷新已就位的列/项目中的列/项目时,实际上不需要有两个控件。如果您必须拥有这两个控件,则可以将它们添加到 sizer 并根据需要隐藏/显示它们,或者使用 sizer Replace(oldWin, newWin) 函数。
更多 wxSizer 信息可以在此处找到。
如果这不是您所指的,那么我建议您为您的问题添加更多细节,因为它有点模糊。 ;)
I'm not quite sure what you are trying to do but I am going to take a guess at it and say that you have two ListCtrl's within your gui and you want to be able to switch between them?
If so, I guess my first suggestion would be to just reuse s single ListCtrl for both purposes, there really is no need to have two controls when you can simply refresh the columns/items within the one that is already in-place. If you MUST have both controls, you could just add both to the sizer and hide/show them as needed, or use the sizers Replace(oldWin, newWin) function.
More wxSizer information can be found here.
If this is not what you were referring to than I would suggest that you add bit more detail to your question as it is a bit vague. ;)