Install & Compatibility
Where this runs
tested against v0.1.12.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.0s · import 0.000s · 18MB
19MB installed
● package 19MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SysTrayIcon
✓ from infi.systray import SysTrayIcon
✗ from infi.systray import SysTrayIcon
This example demonstrates how to create a basic system tray icon with a menu on Windows. It uses a system icon from `shell32.dll` to ensure the example is runnable without requiring a separate `.ico` file. Right-click the tray icon to see the 'Hello' and 'Goodbye' options, and 'Quit' to terminate the application. Note that `infi.systray` is Windows-specific and this example will only function on Windows.
import os
import sys
from infi.systray import SysTrayIcon
# This quickstart is designed for Windows environments ONLY,
# as infi.systray relies on Windows API calls.
# Define menu options and callbacks
def on_hello(systray_instance):
print("Hello menu item clicked!")
def on_goodbye(systray_instance):
print("Goodbye menu item clicked!")
def on_quit_callback(systray_instance):
print("Exiting application from tray icon...")
# It's crucial to force exit because systray.start() is blocking.
os._exit(0) # Terminate the process
# Define the menu structure: (MenuItemText, IconPathForMenuItem, CallbackFunction)
menu_options = (
("Hello", None, on_hello),
("Goodbye", None, on_goodbye),
)
# Specify an icon. For a runnable example on Windows without external files,
# we can use a system-provided icon from a DLL. 'shell32.dll,1' often points
# to a generic application icon.
# NOTE: This path is Windows-specific.
icon_source = r"C:\Windows\System32\shell32.dll,1"
print("Starting infi.systray application...")
print("Look for an icon in your Windows system tray (usually bottom-right).")
print("Right-click the icon to see the menu. Select 'Quit' to terminate.")
# Create the SysTrayIcon instance
systray = SysTrayIcon(
icon_source,
"My infi.systray App", # Text displayed when hovering over the icon
menu_options,
on_quit=on_quit_callback,
default_menu_index=0 # Double-click action (e.g., triggers first menu item)
)
# Start the system tray icon. This call blocks the current thread until the
# on_quit_callback is triggered and calls os._exit(0).
systray.start()
print("Application has stopped.") # This line is generally not reached due to os._exit(0)
Upgrade
Version history
0.1.12.1latest on PyPI · released Jan 11, 2025
Audit
Dependencies
infi.osrequiredInternal dependency for operating system abstractions.
pywin32requiredRequired for Windows API interactions to manage the system tray icon.