制作一个Python/GTK CheckMenuItem,点击时不关闭菜单
使用 Python 和 PyGTK,我得到了一个 GtkMenu,其中包含各种 GtkCheckMenuItems。当用户单击复选框之一时,菜单将关闭。我希望用户能够检查一系列复选框,而无需每次都关闭菜单。
我已经考虑过使用激活回调来显示菜单,但这似乎不起作用。有什么建议吗?
Using Python and PyGTK I've got a GtkMenu with various GtkCheckMenuItems in it. When the user clicks one of the checkboxes the menu closes. I'd like for the user to be able to check a series of checkboxes without the menu closing each time.
I've looked at using the activate callback to show the menu but this doesn't seem to work. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在这里看到问题,
“激活”
信号不允许您返回一个布尔值来判断是否希望信号继续传播。听起来您可能需要浏览 gtk.CheckMenuItem 内部结构,在"activate"
信号关闭菜单后立即触发一个信号,在当前要处理的位置“重新打开”菜单,或者尝试 邮件列表。可能值得注意的是,这更像是一个 GTK+ 问题,而不是 PyGTK,因为我相信 PyGTK API 密切反映了 GTK+ 在这个问题上的问题。
I see the problem here, the
"activate"
signal does not allow you to return a boolean as to whether you wish the signal to propagate onwards. It sounds like you may need to poke around the gtk.CheckMenuItem internals, fire a signal that "reopens" the menu at the current position to be processed immediately after the"activate"
signal has closed down the menu, or try the mailing list.It's probably worth noting this is more of a GTK+ question than a PyGTK, as I believe the PyGTK API reflects the GTK+ one closely on this issue.
尝试深入研究源代码及其文档。我发现这是最简单的方法,也是最好的捷径。
Try digging into source and it's documentation. I have found this to be the easiest way and best shortcut.