qed*_*qed 2 python macos qt pyside cx-freeze
我正在带有 Retina 显示屏的 macbook pro 上构建一个 pyside 应用程序,这是我的安装文件:
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os", "sys", "PySide", "datetime", "subprocess"], "excludes": ["tkinter"]}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
options = {
'build_exe': {
'includes': 'atexit'
}
}
executables = [
Executable('countdown.py', base=base)
]
setup( name = "Countdown",
version = "0.1",
description = "Countdown timer",
options = options,
executables = executables)
Run Code Online (Sandbox Code Playgroud)
然后我构建了我的应用程序:
python3.3 setup.py bdist_mac
Run Code Online (Sandbox Code Playgroud)
countdown_0.1.app 工作正常,只是 gui 有点模糊:
与直接执行 countdown.py 相比:
我想知道为什么它们看起来如此不同?
cx_Freeze 生成的包NSHighResolutionCapable
在其 Info.plist 文件中缺少布尔条目[1],因此应用程序以“放大”模式运行。
复制现有的 Info.plist(在您的情况下,Countdown-0.1.app/Contents/Info.plist
)到 setup.py 所在的目录。在这个例子中,修改后的 Info.plist 将被命名为 Info-highres.plist
使用文本编辑器打开 Info-highres.plist 并将此条目添加到字典中:
<key>NSHighResolutionCapable</key>
<true/>
Run Code Online (Sandbox Code Playgroud)
或者,如果您愿意,可以使用 Xcode plist 编辑器添加条目。
使用下面的设置命令,默认的 Info.plist 将被修改后的 Info-highres.plist 替换,你的应用程序将“准备好视网膜”。
python setup.py bdist_mac --custom-info-plist Info-highres.plist
您还可以将custom_info_plist
指令插入到 setup.py 脚本中。请参阅http://cx-freeze.readthedocs.org/en/latest/distutils.html#bdist-mac