[英]How to create a mac app from python files
I currently have a python application that runs perfectly from the CLI and when I run it from an IDE. 我目前有一个可以从CLI完美运行的python应用程序,也可以从IDE运行该应用程序。 I want to make it into an application that will launch in 1 click from any mac computer.
我想使其成为可在任何Mac计算机上一键启动的应用程序。 (Like any desktop application).
(就像任何桌面应用程序一样)。 Ideally, I can send someone the file, they do a simple install, then the program works.
理想情况下,我可以向某人发送文件,他们进行简单的安装,然后程序可以工作。 I have tried using platypus (works great for 1 file programs) and other methods of bundling apps.
我尝试使用platypus(适用于1个文件程序)和捆绑应用程序的其他方法。 But none of them seem to work as the program is kinda complex.
但是它们似乎都不起作用,因为该程序有点复杂。
Program Requirements: 计划要求:
Python3 Python3
Python Libraries tkinter, socket, threading, PIL etc Python库tkinter,套接字,线程,PIL等
~8 individual python files (controlled by 1 main menu) 〜8个单独的python文件(由1个主菜单控制)
Lots of images 很多图像
I would like to have an install process, where you click next a bunch of times and agree to things, but if this isn't possible I can live without it. 我希望有一个安装过程,在此过程中您单击几下并表示同意,但是如果不可能,我可以没有它。
Any help is greatly appreciated! 任何帮助是极大的赞赏!
Use PyInstaller to build your package. 使用PyInstaller构建您的软件包。 I do not think they have an actual installer, but you could build your own GUI installer by using some CMD commands and something like tkinter.
我认为他们没有真正的安装程序,但是您可以使用一些CMD命令和类似tkinter的工具来构建自己的GUI安装程序。
I have used py2app for this in the past ( https://py2app.readthedocs.io/en/latest/ ) 我过去曾经为此使用py2app( https://py2app.readthedocs.io/en/latest/ )
This article does a good job of explaining how to use it ( https://www.metachris.com/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/ ) 本文很好地解释了如何使用它( https://www.metachris.com/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/ )
Basically you install the library and create a setup.py file that looks something like this 基本上,您安装库并创建一个看起来像这样的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'],
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.