Search code examples
pythonqtpyqtqt-designercx-freeze

PYQT resources, frozen programs


Issue/question with PyQT / resources / cx_freeze on Windows:

I'm using QT's resource system to set an application icon. (Goes in the top left corner of the Window for Windows programs) I created the resource in Designer, then used pyrcc4 to create a rc.py file. It works properly on my uncompiled program, but fails to show (Shows the generic windows program icon instead) when compiling the script with cx_freeze. Note that I am not referring to the icon you click to launch the program - that's not handled by QT, and works properly. Any ideas? This is my setup.py.

from sys import platform
from cx_Freeze import setup, Executable

import module_locator

_dir = module_locator.module_path()

base = None
if platform == "win32":
    base = "Win32GUI"

setup(
    name = "Plates",
    version = "0.1",
    description = "Downloads approach plates",
    executables = [Executable(_dir + '\\plates.pyw',
    base = base, icon = _dir + '\\icon.ico')],
    )

I get no errors when building the program. My rc file does exist (as a compiled python file) in library.zip.


Solution

  • Reposting as an answer:

    Qt needs plugins to display some image formats. Look for a folder called 'imageformats' and copy it into your application directory (next to the exe).

    The next version of cx_Freeze should find and copy imageformats automatically when you use QtGui.