I want to use pystray
module in python to create a system tray app on Windows. Until now I managed to write this:
import pystray
from PIL import Image
image = Image.open("image.gif")
icon = pystray.Icon(name ="SPAM!", icon =image, title ="MOBASuite", menu =None)
icon.run()
I had a hard time to find out how this works. Its not clearly explained in a documentation.
How can I create a menu after rightclicking on the icon and how can I add items to the menu and set default one, which should be called if I click on the icon with left button. And how can I update the icon? If I run the this program, 3 icons are created and Imust hover mouse over them to become one icon. Same thing when I close the program.
from pystray import MenuItem as item
import pystray
from PIL import Image
def action():
pass
image = Image.open("image.jpg")
menu = (item('name', action), item('name', action))
icon = pystray.Icon("name", image, "title", menu)
icon.run()
This work for me
I recomend use lambda to call a method
item('Call something', lambda : method())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With