找出 wxPython 中的嵌套子菜单选择?
假设在深度为 3 级的较大子菜单结构中,我在第一级选择了 'car'
,在第二级选择了 'type'
,然后选择了 'suv'
在第三个也是最后一个级别。有什么方法可以在我的 def OnPopupItemSelected(self, event)
方法中计算出所有这三个选择?
我希望我已经说得足够清楚了,如果没有,请添加评论,以便我重新措辞。
Let's say in a larger submenu structure with a depth of 3 levels, I have selected 'car'
in the first level, 'type'
in the second, and 'suv'
in the third and last level. Is there any way I can figure all these three selections in my def OnPopupItemSelected(self, event)
method?
I hope I have made myself clear enough, if not, please add a comment so I can re-phrase.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来在 wxPython 演示中,他们以子父方式“编码” ids:
我想肯定给定“单击”菜单项,您可以向后移动子菜单。情况似乎并非如此,因为单击的菜单项仅保留对其父菜单的引用,而不是其子菜单的菜单项。
所以,我能编写的最好的代码是一个令人讨厌的递归函数,它从上到下遍历以找到单击的子菜单。
It looks like in the wxPython demo that they "code" the ids in a child parent fashion:
I thought surely given the "clicked" menuitem you could walk the submenus backwards. This doesn't seem to be the case, as the clicked menuitem only holds a reference to it's parent menu and not the menuitem it is a submenu of.
So, the best I could code up was a nasty recursive function that walks top/down to find the submenu clicked.