如何从 python 个文件创建 mac 应用程序
How to create a mac app from python files
我目前有一个 python 应用程序,它 运行 完全来自 CLI,当我 运行 它来自 IDE 时。我想将其制作成一个应用程序,只需单击一下即可从任何 mac 计算机启动。 (就像任何桌面应用程序一样)。理想情况下,我可以将文件发送给某人,他们进行简单的安装,然后程序就可以运行了。我尝试过使用鸭嘴兽(适用于 1 文件程序)和其他捆绑应用程序的方法。但是 none 似乎可以正常工作,因为程序有点复杂。
计划要求:
Python3
Python 库 tkinter、套接字、线程、PIL 等
~8 个单独的 python 文件(由 1 个主菜单控制)
很多图片
我想要一个安装过程,您可以在其中多次单击下一步并同意,但如果这不可能,我可以没有它。
非常感谢任何帮助!
使用 PyInstaller 构建您的包。我认为他们没有实际的安装程序,但您可以使用一些 CMD 命令和类似 tkinter 的东西来构建自己的 GUI 安装程序。
我过去为此使用过 py2app (https://py2app.readthedocs.io/en/latest/)
这篇文章很好地解释了如何使用它(https://www.metachris.com/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/)
基本上你安装库并创建一个看起来像这样的setup.py文件
from setuptools import setup
APP = ['Sandwich.py']
APP_NAME = "SuperSandwich"
DATA_FILES = []
OPTIONS = {
'argv_emulation': True,
'iconfile': 'app.icns',
'plist': {
'CFBundleName': APP_NAME,
'CFBundleDisplayName': APP_NAME,
'CFBundleGetInfoString': "Making Sandwiches",
'CFBundleIdentifier': "com.metachris.osx.sandwich",
'CFBundleVersion': "0.1.0",
'CFBundleShortVersionString': "0.1.0",
'NSHumanReadableCopyright': u"Copyright © 2015, Chris Hager, All Rights Reserved"
}
}
setup(
name=APP_NAME,
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
我目前有一个 python 应用程序,它 运行 完全来自 CLI,当我 运行 它来自 IDE 时。我想将其制作成一个应用程序,只需单击一下即可从任何 mac 计算机启动。 (就像任何桌面应用程序一样)。理想情况下,我可以将文件发送给某人,他们进行简单的安装,然后程序就可以运行了。我尝试过使用鸭嘴兽(适用于 1 文件程序)和其他捆绑应用程序的方法。但是 none 似乎可以正常工作,因为程序有点复杂。
计划要求:
Python3
Python 库 tkinter、套接字、线程、PIL 等
~8 个单独的 python 文件(由 1 个主菜单控制)
很多图片
我想要一个安装过程,您可以在其中多次单击下一步并同意,但如果这不可能,我可以没有它。
非常感谢任何帮助!
使用 PyInstaller 构建您的包。我认为他们没有实际的安装程序,但您可以使用一些 CMD 命令和类似 tkinter 的东西来构建自己的 GUI 安装程序。
我过去为此使用过 py2app (https://py2app.readthedocs.io/en/latest/)
这篇文章很好地解释了如何使用它(https://www.metachris.com/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/)
基本上你安装库并创建一个看起来像这样的setup.py文件
from setuptools import setup
APP = ['Sandwich.py']
APP_NAME = "SuperSandwich"
DATA_FILES = []
OPTIONS = {
'argv_emulation': True,
'iconfile': 'app.icns',
'plist': {
'CFBundleName': APP_NAME,
'CFBundleDisplayName': APP_NAME,
'CFBundleGetInfoString': "Making Sandwiches",
'CFBundleIdentifier': "com.metachris.osx.sandwich",
'CFBundleVersion': "0.1.0",
'CFBundleShortVersionString': "0.1.0",
'NSHumanReadableCopyright': u"Copyright © 2015, Chris Hager, All Rights Reserved"
}
}
setup(
name=APP_NAME,
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)