MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / SystemTray

Class SystemTray

PySimpleGUI/PySimpleGUI.py:12881–13134  ·  view source on GitHub ↗

A "Simulated System Tray" that duplicates the API calls available to PySimpleGUIWx and PySimpleGUIQt users. All of the functionality works. The icon is displayed ABOVE the system tray rather than inside of it.

Source from the content-addressed store, hash-verified

12879# Tray CLASS #
12880# ------------------------------------------------------------------------- #
12881class SystemTray:
12882 """
12883 A "Simulated System Tray" that duplicates the API calls available to PySimpleGUIWx and PySimpleGUIQt users.
12884
12885 All of the functionality works. The icon is displayed ABOVE the system tray rather than inside of it.
12886 """
12887
12888 def __init__(self, menu=None, filename=None, data=None, data_base64=None, tooltip=None, metadata=None):
12889 """
12890 SystemTray - create an icon in the system tray
12891 :param menu: Menu definition. Example - ['UNUSED', ['My', 'Simple', '---', 'Menu', 'Exit']]
12892 :type menu: List[List[List[str] or str]]
12893 :param filename: filename for icon
12894 :type filename: (str)
12895 :param data: in-ram image for icon (same as data_base64 parm)
12896 :type data: (bytes)
12897 :param data_base64: base-64 data for icon
12898 :type data_base64: (bytes)
12899 :param tooltip: tooltip string
12900 :type tooltip: (str)
12901 :param metadata: User metadata that can be set to ANYTHING
12902 :type metadata: (Any)
12903 """
12904 self._metadata = None
12905 self.Menu = menu
12906 self.TrayIcon = None
12907 self.Shown = False
12908 self.MenuItemChosen = TIMEOUT_KEY
12909 self.metadata = metadata
12910 self.last_message_event = None
12911
12912 screen_size = Window.get_screen_size()
12913
12914 if filename:
12915 image_elem = Image(filename=filename, background_color='red', enable_events=True, tooltip=tooltip, key='-IMAGE-')
12916 elif data_base64:
12917 image_elem = Image(data=data_base64, background_color='red', enable_events=True, tooltip=tooltip, key='-IMAGE-')
12918 elif data:
12919 image_elem = Image(data=data, background_color='red', enable_events=True, tooltip=tooltip, key='-IMAGE-')
12920 else:
12921 image_elem = Image(background_color='red', enable_events=True, tooltip=tooltip, key='-IMAGE-')
12922 layout = [
12923 [image_elem],
12924 ]
12925 self.window = Window('Window Title', layout, element_padding=(0, 0), margins=(0, 0), grab_anywhere=True, no_titlebar=True, transparent_color='red',
12926 keep_on_top=True, right_click_menu=menu, location=(screen_size[0] - 100, screen_size[1] - 100), finalize=True)
12927
12928 self.window['-IMAGE-'].bind('<Double-Button-1>', '+DOUBLE_CLICK')
12929
12930 @property
12931 def metadata(self):
12932 """
12933 Metadata is an SystemTray property that you can use at any time to hold any value
12934 :return: the current metadata value
12935 :rtype: (Any)
12936 """
12937 return self._metadata
12938

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected