删除默认的“Python"Mac OSX 上带有 Tkinter 菜单的子菜单 [英] Remove default "Python" submenu with Tkinter Menu on Mac OSX

查看:35
本文介绍了删除默认的“Python"Mac OSX 上带有 Tkinter 菜单的子菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Mac OSX 上的 Tkinter 中创建菜单时,第一个子菜单标记为Python".有没有办法删除它,以便唯一的子菜单是我创建的子菜单,或者无论如何该子菜单始终存在?

When creating a Menu in Tkinter on Mac OSX, the very first submenu is labeled "Python". Is there a way to remove this so that the only submenus are the ones that I have created or does that submenu always exist no matter what?

这是我创建菜单的方式

root = self.winfo_toplevel()
self.menu = Menu(root)
root['menu'] = self.menu
self.sub_menu = Menu(self.menu)
self.menu.add_cascade(label='My Program', menu=self.sub_menu)
self.sub_menu.add_command(label='Quit', command=self.quit)

推荐答案

我能够重命名第一个菜单标题的唯一方法是将 python 编译为应用程序.我使用 py2app 做到了这一点.

The only way I've been able to rename the first Menu title is to compile the python to an application. I did this using py2app.

我有一个示例应用,你可以在这里看到:

I have an example app you can see here:

https://bitbucket.org/jgrigonis/mathfacts/overview

关键代码在这个文件中:

The key code is in this file:

https://bitbucket.org/jgrigonis/mathfacts/src/b994b6225743/setupmac.py

这篇关于删除默认的“Python"Mac OSX 上带有 Tkinter 菜单的子菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆