I modified Simon Brunning’s epic example (original can be found here) to include an example of how to have a windows system tray icon display a popup on demand. Here’s the coding:
The differences are:
- Added a new method to the sysTrayIcon class called “set_popup”. This is where win32 api does it’s magic and calls up a popup.
- Note that “set_popup” makes use of two variables defined in the __init__ method (self.popup_title and self.popup_msg), the names of the variables are self explanatory. These two variables are set when instantiating the sysTrayIcon class in the very last line of the script, feel free to change these
- I substituted one of the menu options (in menu_options) with the line: (‘Show Popup’, None, icon_popup)
- Icon_popup is a caller method, accessed by the menu option I mentioned above, which calls the “set_popup” method of the “sysTrayIcon” class