各位朋友们,小编在这里要分享,用python写的好玩的小程序 python简单易懂的小程序,一起探索吧!
这篇文章主要介绍了mac系统python程序打包成exe,具有一定借鉴价值,需要的朋友可以参考下好用简单的PHP后台框架的重要性。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。
1.第一步首先创建Tkinter应用,命名为
import sys
import tkinter as tk
root = ()
root.title("Sandwich")
tk.Button(root, text="Make me a Sandwich").pack()
tk.mainloop()
2.安装 py2app
3.创建文件
py2applet --make-setup
自动生成的 文件内容为
from setuptools import setup
APP = ['']
DATA_FILES = []
OPTIONS = {'argv_emulation': True}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
如果你的应用使用的其他文件,比如 JSON 文件,文本文件,图片等,你应该将他们包含在 DATA_FILES 中。 例如:
DATA_FILES = ['', '']
4.发布
创建测试版
python py2app -A
此时对的修改,app会立刻生效
可以通过命令
open 或者
启动
构建发布版应用
确保旧的 build 和 dist 文件类都被删除了:
rm -rf build dist
python py2app
此时对的修改都要重新打包
5.添加图标
在 OPTIONS 字典中添加 "iconfile": "" 即可:
from setuptools import setup
APP = ['']
DATA_FILES = []
OPTIONS = {
'argv_emulation': True,
'iconfile': ''
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
你可以在网上找到 icns 格式的图标(例如:IconFinder或者freepik)python学生作品。
应用高级设置
你可以通过修改 Info.plist 来调用应用的信息各行为。最完整的对可用的键的引用是Apple's Runtime Configuratin Guidelines。
# -*- coding: utf-8 -*-
from setuptools import setup
APP = ['']
APP_NAME = "SuperSandwich"
DATA_FILES = []
OPTIONS = {
'argv_emulation': True,
'iconfile': '',
'plist': {
'CFBundleName': APP_NAME,
'CFBundleDisplayName': APP_NAME,
'CFBundleGetInfoString': "Making Sandwiches",
'CFBundleIdentifier': ".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'],
)
创建icns图标的方式
创建目录
mkdir test.iconset // 这里后缀必须是 iconset cd test.iconset
执行命令
$ sips -z 16 16 --out
$ sips -z 32 32 --out // 2x是专供Retina屏幕使用的
$ sips -z 32 32 --out
$ sips -z 64 64 --out
$ sips -z 128 128 --out
$ sips -z 256 256 --out
$ sips -z 256 256 --out
$ sips -z 512 512 --out
$ sips -z 512 512 --out
$ sips -z 512 512 --out
最后执行
iconutil -c icns tmp.iconset -o
把放在目录下,即可。
参考地址
png格式图片 转 icns格式图标_如何转为icns-CSDN博客
原文地址1:https://blog.csdn.net/2301_81837718/article/details/135913921
参考资料:python中用turtle画一个圆形 https://blog.csdn.net/SXIAOYAN_/article/details/140061099