Skip to content

window.icon when packaged as app doesn't work #222

@dwightmulcahy

Description

@dwightmulcahy

So I'm guessing that py2app misses something when it packages my app, but if I use the following code the window never shows/runs.

I know that when I package the app that it will use the app icon for the window dialog but what if I wanted to be something else?

To fix this, I just removed the window.icon = ... line and it's all happy now.

...
         window = rumps.Window(
            message="Test",
            title=f"Test Window",
            default_text="Test Text",
            ok='Close',
            dimensions=(200, 200),
         )

         window.icon = '../images/coinglass.png'    # DOESN'T RETURN/CONTINUE FROM HERE...

         window.run()    # NEVER RUNS... 
...

Looking at rumps, it seems like it does this when you set an icon for a window... I guess the _nsimage_from_file is causing problems, but I never receive an exception.

...
    @icon.setter
    def icon(self, icon_path):
        new_icon = _nsimage_from_file(icon_path) if icon_path is not None else None
        self._icon = icon_path
        self._alert.setIcon_(new_icon)
...

my setup.py used to package the app...

from setuptools import setup

APP = ['./src/my_test_app.py']
DATA_FILES = []
OPTIONS = {
    'argv_emulation': False,
    'plist': {
        'LSUIElement': False,
    },
    'packages': [
...
    ],
    'iconfile': './images/coinglass.png',
}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],

    name='test',
    version='0.1.0',
    url='',
    license='MIT License',
    author='dWiGhT',
    author_email='',
    description=''
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions