如何使用Pyinstaller打包的Kivy Python应用程序在OSX菜单栏中创建菜单项? [英] How to create menu item in OSX Menubar using Pyinstaller packaged Kivy Python application?

查看:172
本文介绍了如何使用Pyinstaller打包的Kivy Python应用程序在OSX菜单栏中创建菜单项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在我的Pyinstaller打包的Kivy Python应用程序中获得本机感,我想在OSX菜单栏中创建菜单项.如果使用PyQt,我可以轻松实现.但是当我使用Kivy时,似乎不得不采取其他方法.

To achieve sense of nativeness in my Pyinstaller packaged Kivy Python application, I would like to create menu item in OSX menu bar. If using PyQt, I can easily achieve this. But as I am using Kivy, it seems like I have to resort to other ways.

有什么建议吗?我想它将在PyObjc或AppleScript的范围内.不确定.

Any suggestion? I guess it will be in the range of PyObjc or AppleScript. Not sure though.

推荐答案

我想这更多是Pyinstaller问题,就像Kivy问题一样.

I guess this is more to Pyinstaller question that it is as Kivy question.

都不是:)

PyInstaller只是将python应用程序包装到一个看起来本机的OS X应用程序包中.
由于Kivy无法在OS X中创建菜单栏图标,因此您必须坚持使用PyObjC.

PyInstaller just wraps the python application into a native-looking OS X application bundle.
Since Kivy doesn't have the ability to create a menu bar icon in OS X, you have to stick with PyObjC.

首先,您必须安装Xcode(如果尚未安装).您可以从App Store或 Apple的开发人员中心下载它.

First, you've got to install Xcode (if not installed yet). You can download it from the App Store or from the Apple's Developer Center.

然后安装PyObjC本身:

Then install PyObjC itself:

pip install pyobjc

已经有一些示例(第一

There are already some examples (first, another) on creating a status bar icon using PyObjC.

还有一个很棒的库,叫做 rumps ,大大简化了制作状态栏所需的代码图标,菜单和操作.也许它可以帮助您与状态栏进行交互.

There's also an awesome library called rumps which greatly simplifies the code needed to make status bar icons, menus and actions. Perhaps it may help you with status bar interacting.

这篇关于如何使用Pyinstaller打包的Kivy Python应用程序在OSX菜单栏中创建菜单项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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