Windows Systems Tray May 2026
return image def on_quit(icon, item): icon.stop()
def on_open_settings(icon, item): print("Settings clicked - open a config window") icon = pystray.Icon( "windows_tray_example", create_icon_image(), title="My Windows Tray App", menu=pystray.Menu( pystray.MenuItem("Show Info", on_show_info), pystray.MenuItem("Settings", on_open_settings), pystray.Menu.SEPARATOR, pystray.MenuItem("Exit", on_quit) ) ) --- Optional: run a background thread alongside the tray --- def background_task(): while icon.running: # Do periodic work here (e.g., check updates) time.sleep(5) print("Background task running...") --- Run the tray icon (blocks main thread) --- if name == " main ": # Start background thread thread = threading.Thread(target=background_task, daemon=True) thread.start() windows systems tray
import pystray from PIL import Image, ImageDraw import threading import time def create_icon_image(): # Icon size (Windows tray expects small, e.g., 16x16 or 24x24) width = 64 height = 64 image = Image.new('RGB', (width, height), (255, 255, 255)) draw = ImageDraw.Draw(image) return image def on_quit(icon, item): icon
# Draw a simple Windows-like colored circle draw.ellipse((10, 10, width-10, height-10), fill=(0, 120, 215), outline=(0, 0, 0)) draw.rectangle((width//2-8, height//2-2, width//2+8, height//2+2), fill=(255, 255, 255)) draw.rectangle((width//2-2, height//2-8, width//2+2, height//2+8), fill=(255, 255, 255)) return image def on_quit(icon
Here’s a clean, functional implementation of a using Python ( pystray ) and PIL. It creates an icon in the system tray with a right-click menu.
def on_show_info(icon, item): print("Info clicked - you can add a notification here")