Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate tuple to Menu object to keep consistency with constructor when set tuple value to menu #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pmh905001
Copy link

@pmh905001 pmh905001 commented Nov 6, 2023

User can pass tuple object as menu in constructor of Icon, so the value of menu.setter should support to be tuple object. This can fix the issue that invisible menu item is displayed after updating menu. For example:

import pystray
from PIL import Image
from pystray import MenuItem

def checked_item(icon, item):
icon.menu = (
MenuItem(text='item 2', action=checked_item),
MenuItem(text='Invisible item', action=lambda icon, item: print('default action'), default=True, visible=False),
)

pystray.Icon(
name="icon_name",
icon=Image.open(r'icon.png'),
title='app_name',
menu=(
MenuItem(text='item 1', action=checked_item),
MenuItem(text='Invisible item', action=lambda icon, item: print('default action'), default=True, visible=False),
)
).run()

you would see that 'Invisible item' displayed in menu.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant