Get left / right click on the tray icon
Hello, I am looking to get a left- /right click on the tray icon so I can create my own window on click. Is there any way to do that without a window being created by psgtray?
The repo has an example of a "Windowless" program. You must have a PySimpleGUI window, however, it doesn't have to ever be visible.
https://github.com/PySimpleGUI/psgtray/blob/main/Demo_System_Tray_Icon_psgtray_No_Window.py
Have your event loop create a window and run an event loop for that window. Since the "Window controlling the tray" isn't visible, it will appear as if you've only got 1 window, even though you have 2.
If I add a menu item "popup" and this statement to the event loop in the example;:
elif event == 'popup':
sg.popup('created a window of my own...')
Then I'll get this popup when the menu item is clicked. This is where you would add your window instead of the popup.
BTW, the reason for the requirement of the window in this use of PySimpleGUI is that the events from the system tray come through the window as events. You need that window.read in order to receive the events. It's not the same as the SystemTray implementation of PySimpleGUIQt and PySimpleGUI tkinter (that simulates a system tray icon)