Reputation: 1
Following this post, I've implemented to minimize the window of a app to system tray.
However, i don't figured out how to restore the window by clicking in the system's tray icon. Only opening the menu and choosing 'show' optin this is possible. Clicking at the icon, a TypeError raises:
File "C:\<path>\pystray\_base.py", line 106, in __call__
self._menu(self)
TypeError: 'tuple' object is not callable
Any hint for me? Thanks
Upvotes: 0
Views: 1929
Reputation: 47173
You need to assign the menu
option an instance of pystray.Menu
instead of passing a tuple:
...
from pystray import Menu, MenuItem, Icon
...
def withdraw_window():
window.withdraw()
image = Image.open("icon.png")
# create instance of pystray.Menu instead of a tuple
menu = Menu(
MenuItem('Quit', quit_window),
MenuItem('Show', show_window, default=True) # set 'Show' as the default action
)
icon = Icon("name", icon=image, title="title", menu=menu)
icon.run()
...
Upvotes: 2