Open AnAnalogGuy opened 1 year ago
To make it short:
Instead of
menuItems.append(MenuItem("Auto Position Change", Menu(menu_intervals)))
it needs to be
menuItems.append(MenuItem("Auto Position Change", Menu(lambda: menu_intervals)))
To highlight the difference: Menu(lambda: menu_intervals)
@moses-palmer This is quite hard to understand from the docs. I'd like to suggest to add a related example.
I am dynamically creating a menu including one submenu, both with a couple of items. The submenu as well as the menu are created the same way as a list object and then being instanced as a pystray.Menu object.
The submenu
The Menu
And then adding it all together:
From the documentation:
While creating and adding a Menu to Icon is working this way, it's running into a runtime error doing the same for Menu used as a submenu.