在 Tkinter 中保持菜单打开
我想在单击级联内的命令按钮后保持菜单级联打开。因此,它基本上仅在用户单击其他任何地方时才会关闭(就像通常一样)。似乎无法找到正确的选项或方法来在回调中打开所述菜单。 invoke() 函数仅适用于级联中的按钮,对吗?你会怎么做呢?
I want to keep a menu cascade open, after a command button within the cascade is clicked. So it basically only closes when the user clicks anywhere else (like it would normally too). Can't seem to find a proper option or a method to open said menu in the callback. The invoke() function only works on buttons wihtin the cascade right? How would you go about that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,我知道这个问题很久以前就被问到了,但我很好奇是否有任何方法可以用 tkinter 来完成这个任务,所以我摆弄了一段时间并弄清楚了如何做到这一点。我无法想出一种方法将持久菜单正确放置在最初打开时的位置,但我设法使其保留在您请求的任何位置(我使用根窗口的左上角)。是的,我知道这不是一个很好的基于类的实现,但我只是想编写一个尽可能简单的测试,而不会用太多无关的细节来模糊它。
Yes, I know this was asked a long time ago, but I was curious if there was any way to accomplish this with tkinter, so I fiddled about for a while and figured out how to do it. I was unable to come up with a way to properly place the persistent menu where it was when it originally opened, but I have managed to make it persist in any location you request (I use upper-left corner of root window). And yes, I know this isn't a nice proper class based implementation, but I was just going for as simple a test as I could write without obscuring it with too many extraneous details.