Reputation: 817
I have a very simple pystray icon with a menu. (Basicaly the normal example code)
Its also working so far. An Icon apears and if I right click it the menu apears.
But so far I couldn't find a way to make the menu show on left-click to.
It seems like there is no way to do that. I cant find anythin withing the pystray documentation also google also doesn't give me any hints.
from pystray import Icon as icon, Menu as menu, MenuItem as item
from PIL import Image, ImageDraw
def create_image(width, height, color1, color2):
# Generate an image and draw a pattern
image = Image.new('RGB', (width, height), color1)
dc = ImageDraw.Draw(image)
dc.rectangle(
(width // 2, 0, width, height // 2),
fill=color2)
dc.rectangle(
(0, height // 2, width // 2, height),
fill=color2)
return image
ico = icon('test', create_image(64, 64, 'black', 'white'), menu=menu(
item(
'With submenu',
menu(
item('Close App', lambda: ico.stop()),
item('Submenu item 2', None)))))
ico.run()
Upvotes: 1
Views: 118