moses-palmer / pystray

GNU General Public License v3.0
463 stars 57 forks source link

Feature request: Starting Actin (autorun action) #79

Closed w3suli closed 3 years ago

w3suli commented 3 years ago

The "default" parameter can now be set for a menu item.

For example, it would be good to introduce a new parameter. His name could be autorun.

If autorun = True for a menu item, the function of the menu item is automatically called when the pystray is started.

This option would implement my previous request and is more useful in my opinion.

Thus, when pystray is started, external functions could be called that can be notified immediately and the resulting information.

It can be useful if a program starts pystray, or if Windows autorun starts pystray

def action():
    #any functions...
    icon.notify(message = 'He program has started', title = 'Pystray started message'

def exit_prg():
    icon.stop()

image = Image.open("C:\\icon.ico")

icon = pystray.Icon('test', image, 'Autorun' , menu=menu(
            item(
                'Show message', action, default = True, autorun = True),
            item(
                'Quit', exit_prg)))
icon.run()
moses-palmer commented 3 years ago

Thank you for your request.

I believe this can be accomplished by using the setup argument, so i will close this issue. If that is not the case, please reopen.