Infinidat / infi.systray

Windows system tray icon
BSD 3-Clause "New" or "Revised" License
215 stars 40 forks source link

updating menu options (maybe a feature request) #17

Open MagTun opened 5 years ago

MagTun commented 5 years ago

I have a script that can run either in mute mode and unmute mode. I would like to be able to switch between these two mode by right-clicking on the icon of my script in the systray menu and selecting a menu. So far, the only way I could to do this with infi.systray is by having 2 menu options, one mute and the other one unmute.

Would it be possible to only have a single menu option whose label would be "mute" when my script is unmute and whose label would be unmute when my script is mute.

Maybe we could also have menu with checkmark. so the label would always be for instance mute and then with either a checkmark or not.

Thanks for sharing your work!

WiliTest commented 5 years ago

+1: Yes, it would be great to have some ON/OFF, ENABLED/DISABLED on a dynamic menu.

wiggin15 commented 5 years ago

Unfortunately, I won't have time to work on this, but I am open to pull requests.

MagTun commented 5 years ago

I have created 2 pull requests (one for traybar.py and one for readme.md).

Syazvinski commented 3 years ago

I have created 2 pull requests (one for traybar.py and one for readme.md).

Has this been implemented? I get the error TypeError: update() got an unexpected keyword argument 'menu_options' When using the below code.

from infi.systray import SysTrayIcon

def say_hello(systray):
        systray.update(menu_options=menu_optionsbye)
def say_bye(systray):
        systray.update(menu_options=menu_optionshello)
menu_optionshello = (("Say Hello","hello.ico", say_hello),)
menu_optionsbye = (("Say Bye", "bye.ico", say_bye),)
systray = SysTrayIcon("icon.ico", "Hello/Bye", menu_optionshello)   
systray.start()
danperks commented 3 years ago

I was just about to post this. The pull requests from @MagTun have been included, but the updates have not been pushed to the version available from pip install infi.systray. If someone could push this update to pip, that'd be great :) @wiggin15

odoluca commented 3 years ago

any update on this?