Skip to content

System Tray

A system tray icon widget for desktop integration.

FXSystemTray

Bases: QObject

A system tray icon with a context menu.

Parameters:

Name Type Description Default

parent

QWidget

The parent widget. Defaults to None.

None

icon

str

The icon path. Defaults to None.

None

Attributes:

Name Type Description
tray_icon QSystemTrayIcon

The system tray icon.

quit_action QAction

The action to quit the application.

tray_menu QMenu

The tray menu.

Methods:

Name Description
show

Shows the system tray icon.

on_tray_icon_activated

Shows the tray menu above the taskbar.

closeEvent

Closes the application.

Examples:

>>> app = FXApplication()
>>> system_tray = FXSystemTray()
>>> hello_action = QAction(
...     fxicons.get_icon("visibility"), "Set Project", system_tray
... )
>>> system_tray.tray_menu.insertAction(
...     system_tray.quit_action, hello_action
... )
>>> system_tray.tray_menu.insertSeparator(system_tray.quit_action)
>>> system_tray.show()
>>> app.exec_()
Note

Inherits from QObject, not QSystemTrayIcon.

add_action

add_action(action: QAction) -> None

Adds an action to the tray menu.

Parameters:

Name Type Description Default

action

QAction

The action to add to the tray menu.

required

set_icon

set_icon(icon_path: str) -> None

Sets a new icon for the system tray.

Parameters:

Name Type Description Default

icon_path

str

The path to the new icon.

required

show

show()

Shows the system tray icon.