Search code examples
pythonmacosqtpysidecx-freeze

cxfreeze produces fuzzy gui on macbook pro with retina display


I am building an pyside app on a macbook pro with retina display, and here is my setup file:

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)

Then I built my app with:

python3.3 setup.py bdist_mac

The countdown_0.1.app works ok, except that the gui is a little fuzzy:

enter image description here

when compared to executing countdown.py directly:

enter image description here

I am wondering why they look so different?


Solution

  • The bundle produced by cx_Freeze lacks the boolean entry NSHighResolutionCapable[1] in its Info.plist file, so the app runs in "magnified" mode.

    Copy the existing Info.plist (in your case,Countdown-0.1.app/Contents/Info.plist) to the directory where your setup.py is located. In this example, the modified Info.plist will be named Info-highres.plist

    Open Info-highres.plist with a text editor and add this entry to the dictionary:

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

    or, if you prefer, use the Xcode plist editor to add the entry.

    Using the setup command below, the default Info.plist will be replaced by the modified Info-highres.plist and your app will be "retina-ready."

    python setup.py bdist_mac --custom-info-plist Info-highres.plist

    You can also insert the custom_info_plist directive into your setup.py script. See 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 (Figure 1-8)