cx_freeze在带有视网膜显示的macbook pro上产生模糊gui

时间:2014-09-18 16:35:59

标签: python macos qt pyside cx-freeze

我正在使用视网膜显示器在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)

然后我用以下内容构建了我的应用程序:

python3.3 setup.py bdist_mac

countdown_0.1.app工作正常,除了gui有点模糊:

enter image description here

与直接执行countdown.py相比:

enter image description here

我想知道为什么他们看起来如此不同?

1 个答案:

答案 0 :(得分:4)

cx_Freeze生成的包在其Info.plist文件中缺少布尔条目NSHighResolutionCapable [1],因此应用程序以“放大”模式运行。

将现有Info.plist(在您的情况下为Countdown-0.1.app/Contents/Info.plist)复制到setup.py所在的目录。在此示例中,修改后的Info.plist将命名为Info-highres.plist

使用文本编辑器打开Info-highres.plist并将此条目添加到字典中:

<key>NSHighResolutionCapable</key>
<true/>

或者,如果您愿意,可以使用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

[1] https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html(图1-8)

相关问题