简体   繁体   English

wxPython-禁用整个菜单

[英]wxPython - Disable a whole menu

I have come across a problem while using wxPython lately: I want to grey out a whole wx.Menu and I can't find a way to do it. 我最近在使用wxPython时遇到了一个问题:我想将整个wx.Menu涂成灰色,但找不到解决方法。 I could disable all the wx.MenuItem instances related to the wx.Menu, but I find it less efficient ergonomically speaking than greying out the menu itself. 我可以禁用所有与wx.Menu相关的wx.MenuItem实例,但是从人机工程学的角度来看,它不如将菜单本身变灰。

The wx.Menu class has a method named Enable() which accepts the 'enable' argument, but its solely use is to enable/disable a related wx.MenuItem and not the wx.Menu itself. wx.Menu类具有一个名为Enable()的方法,该方法接受“ enable”参数,但其唯一用途是启用/禁用相关的wx.MenuItem而不是wx.Menu本身。 Actually, I'm not even sure that what I want can be done. 其实,我什至不确定我想要做的事。

However, I would be glad to listen to your solutions if you have some. 但是,如果您有解决方案,我很乐意听听您的解决方案。

Enable is just for the menu items. 启用仅适用于菜单项。 EnableTop should counter-intuitively disable the entire menu. EnableTop应该以违反直觉的方式禁用整个菜单。 See my old tutorial on menus about half-way down for more info. 有关更多信息,请参阅我的菜单上的中级教程 Here's how I did it: 这是我的操作方式:

self.menuBar.EnableTop(0, False)

Note that it's zero-based, so zero is the first menu, one is the second, etc. 请注意,它是从零开始的,因此零是第一个菜单,一个是第二个菜单,依此类推。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM