I want to change the text for an item variably. to do this, i tried to update the menu using update_menu(). unfortunately, this didn't work and i couldn't find anything more detailed in the pystray documentation. I hope you can help me. thank you.
Python:
from pystray import Icon as icon, Menu as menu, MenuItem as item
import PIL.Image
image = PIL.Image.new('RGB', (100, 100), 255)
adapter = 'before'
def test():
global ps
global adapter
adapter = 'after'
ps.update_menu()
ps = icon(name='name', icon=image, menu=menu(
item(text='Adapter', action=menu(item(text='Test', action=test))),
item(text=adapter, action=lambda: test()),
)
)
ps.run()