moses-palmer / pystray

GNU General Public License v3.0
463 stars 57 forks source link

TypeError: pystray._base.Menu() argument after * must be an iterable, not NoneType #114

Closed aixia715 closed 2 years ago

aixia715 commented 2 years ago

On Windows, if I don't pass the "menu" kwarg to pystray.Icon init function just like

icon = pystray.Icon('test name')

it will raise "TypeError: pystray._base.Menu() argument after * must be an iterable, not NoneType"

I think it is because the lack of judgement whether menu is None in the init function of class Icon in the code below.

class Icon(object):

    """..."""

    def __init__(
            self, name, icon=None, title=None, menu=None, **kwargs):
        self._name = name
        self._icon = icon or None
        self._title = title or ''
        self._menu = menu if isinstance(menu, Menu) else Menu(*menu)  # <-- should be "isinstance(menu, Menu) or menu is None"
        self._visible = False
        self._icon_valid = False
        self._log = logging.getLogger(__name__)
moses-palmer commented 2 years ago

Thank you for your report.

The master branch contains a fix for this; there is no release however, since I would like to fix some of the other open issues first.