简体   繁体   English

Python GTK不显示菜单栏

[英]Python GTK does not show menubar

I am a PHP programmer, and want to get into writing Python GUI apps under Linux. 我是一名PHP程序员,想要在Linux下编写Python GUI应用程序。

On my Ubuntu 12.04 computer, with any version of PyGtk the MenuBar simply does not show. 在我的Ubuntu 12.04计算机上,任何版本的PyGtk都没有显示MenuBar。 On my Ubuntu 10.04 computer at work, with exactly the same code, the MenuBar always shows. 在工作的Ubuntu 10.04计算机上,使用完全相同的代码,MenuBar始终显示。

I am trying to learn the up to date way of doing things, so have been using the example at the bottom of this page: http://python-gtk-3-tutorial.readthedocs.org/en/latest/menus.html 我正在尝试学习最新的工作方式,所以一直在使用本页底部的示例: http//python-gtk-3-tutorial.readthedocs.org/en/latest/menus.html

I assume one of you will know the issue straight off? 我假设你们其中一个人会直接知道这个问题?

Thanks. 谢谢。

Doh ! 哇!

Ubuntu 12.04 uses Unity, and Unity shows the menu at the top of the desktop. Ubuntu 12.04使用Unity,Unity显示桌面顶部的菜单。

Doh again ! 再来!

You can find the following answer here : 你可以在这里找到以下答案:

In Unity you can disable the global menu for your program by setting the environment variable $UBUNTU_MENUPROXY to 0 (or anything else that is not "libappmenu.so"). 在Unity中,您可以通过将环境变量$ UBUNTU_MENUPROXY设置为0(或任何其他不是“libappmenu.so”)来禁用程序的全局菜单。 So if for some reason you want to make sure that even in Unity your app shows the menu inside the app window just create a small wrapper shell script that unsets $UBUNTU_MENUPROXY and starts your program. 因此,如果由于某种原因你想要确保即使在Unity中你的应用程序显示应用程序窗口内的菜单,只需创建一个小的包装器shell脚本,取消设置$ UBUNTU_MENUPROXY并启动你的程序。

I came across the same problem but in a C++ project on Ubuntu. 我遇到了同样的问题,但在Ubuntu的C ++项目中。 I have managed to work around by setting the gtk-shell-shows-menubar property to FALSE as below: 我设法通过将gtk-shell-shows-menubar属性设置为FALSE来解决此问题,如下所示:

g_object_set(gtk_settings_get_default(), "gtk-shell-shows-menubar", FALSE, NULL); g_object_set(gtk_settings_get_default(),“gtk-shell-shows-menubar”,FALSE,NULL);

You could translate it to python if you would like. 如果您愿意,可以将其翻译为python。

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

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