Closed LawMixer closed 9 months ago
Have a look at the documentation. In your case, setting the text to a lambda reflecting the state of your application instead of a static string would be the way to go.
I've tried what was written in the documentation, and it does not refresh the value in the system tray. Maybe, I did something wrong and I need a second set of eyes to view my errors, any help would be appreciated, thanks!
import pystray
from PIL import Image
image = Image.open("5968322.png")
state = "Start"
def after_click(icon2: pystray.Icon, query):
global state
if str(query) == "Start":
print("Starting..")
elif str(query) == "Stop":
print("Stopping..")
elif str(query) == "Quit":
icon.stop()
if state == "Start":
state = "Stop"
print(state)
icon.menu = False
icon.menu = menu
menu = pystray.Menu(
pystray.MenuItem("Start", action=after_click, checked=lambda item: state),
pystray.MenuItem("Quit", action=after_click)
)
icon = pystray.Icon("T", image, "Testing", menu=menu)
icon.run()
Wanting to do a timer sort of application for fun, and "Start" is going to be the main thing and then whenever it gets pressed, it gets changed to "Stop"
I'm not sure how to do it or if there's any documentation on it, any help would be appreciated!