Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting left-click on tray icon (Python | Pystray)

I am working on creating a tkinter window when the pystray icon is pressed so I can make my own Menu in the tray. But I have no idea how to get if the tray icon is pressed. Any help is appreciated! Thanks in advance!

like image 227
vSteppY Avatar asked May 18 '26 12:05

vSteppY


1 Answers

You can use something like

icon = pystray.Icon(name="exampleapp",icon=image,title="Example",menu=pystray.Menu(
    pystray.MenuItem(text="Left-Click-Action",action=default_function,default=True),
    pystray.MenuItem(text="Other option",other_function)
))

So you can set the default parameter from a pystray.MenuItem object to True to make it the left-click function.

like image 138
Zitronenenlolli Avatar answered May 20 '26 00:05

Zitronenenlolli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!