Blurred GUI after PyInstaller compilation

79 views
Skip to first unread message

mar...@frightanic.com

unread,
Feb 2, 2021, 11:42:47 AM2/2/21
to PyInstaller
For a GUI application built with wxPython I noticed the GUI becomes all blurry after it is compiled into a binary with PyInstaller. Tried both 3.6 and 4.2 but the effect is largely the same.
Build environement: macOS Big Sur, same with previous versions

Has one of you seen a similar behavior and/or an idea how to fix this?

Running Python app
Screen Shot 2021-02-01 at 22.56.33.png

➜  NodeMCU-PyFlasher git:(master) ✗ python3 --version
Python 3.8.2

Running the binary
Screen Shot 2021-02-01 at 22.57.15.png

Thanks

Jesse Hopkins

unread,
Apr 8, 2021, 3:46:12 AM4/8/21
to PyInstaller
I came here searching for a different wxpython issue, but suspect I know the problem here, as I ran into it a while back. You should set the NSHighResolutionCapable flag in your info.plist file. You can do this in the BUNDLE method using the info_plist command, or manually set it. Here's an example from a program I maintain (where coll is the output of the COLLECT):

if opsys == 'Darwin':
    app = BUNDLE(
        coll,
        name='RAW.app',
        icon=raw_icon,
        bundle_identifier='edu.bioxtas.raw',
        info_plist=
            {
            'CFBundleVersion' : RAWGlobals.version,
            'CFBundleShortVersionString' : RAWGlobals.version,
            'LSBackgroundOnly' : '0',
            'NSHighResolutionCapable' : True,
            'NSPrincipleClass' : 'NSApplication',
            'CFBundleDevelopmentRegion' : 'en_US',
            'LSHasLocalizedDisplayName' : False,
            'CFBundleDocumentTypes' : [
                {
                    'CFBundleTypeName' : 'SAXS data file',
                    'LSHandlerRank' : 'Default',
                    'CFBundleTypeExtensions': ['out', 'fit', 'fir', 'rad',
                        'int', 'dat', 'csv', 'sub', 'txt'],
                    'CFBundleTypeRole' : 'Viewer'
                },
                {
                    'CFBundleTypeName' : 'Image file',
                    'LSHandlerRank' : 'Default',
                    'CFBundleTypeExtensions': ['tif', 'tiff', 'nxs', 'edf',
                        'ccdraw', 'img', 'imx_0', 'dkx_0', 'dxk_1', 'png',
                        'mpa', 'mar1200', 'mar2400', 'mar3200', 'mar3600',
                        'sfrm', 'dm3', 'xml', 'cbf', 'kccd', 'msk',
                        'spr', 'h5', 'mccd', 'mar3450', 'npy', 'No'],
                    'CFBundleTypeRole' : 'Viewer'
                },
                {
                    'CFBundleTypeName' : 'LC data file',
                    'LSHandlerRank' : 'Default',
                    'CFBundleTypeExtensions': ['sec',],
                    'CFBundleTypeRole' : 'Viewer'
                },
            ],
            },
        )

If it's already installed and you overwrite the .app, you might have to force MacOS to update the changes, this set of commands should do it:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications/<my_app>.app /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -seed /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications -all local,user

You may then have to right click on the .app, select ‘Get Info’ and uncheck the box ‘Open in low resolution mode’.

Hope that helps.

- Jesse

mar...@frightanic.com

unread,
Apr 8, 2021, 2:21:04 PM4/8/21
to PyInstaller
Thanks! That build config looks quite a bit more involved than the spec I use :) https://github.com/marcelstoer/nodemcu-pyflasher/blob/master/build-on-mac.spec

Jesse Hopkins

unread,
Apr 9, 2021, 8:20:35 AM4/9/21
to PyInstaller
The full build config is even worse, because it handles windows and linux as well, and includes various resource files :) https://sourceforge.net/p/bioxtasraw/git/ci/master/tree/installer/RAW.spec

If you want a minimal info_plist definition, basically duplicate mine but remove the CFBundleDocumentTypes definition. It's useful to have some info_plist stuff because it defines not just the high resolution capabilities but also gives it a version that display in finder, which is useful. You can also edit the info.plist manually in your .app if you'd like, using either a text editor or XCode.

- Jesse

mar...@frightanic.com

unread,
Apr 9, 2021, 8:20:42 AM4/9/21
to PyInstaller
Btw thanks to https://github.com/pyinstaller/pyinstaller/pull/5230 NSHighResolutionCapable is enabled by default.
Reply all
Reply to author
Forward
0 new messages