{"library":"pystray","title":"pystray","description":"pystray is a Python library that provides cross-platform system tray icon integration. It allows developers to create a system tray icon, define a title, set an image, and attach a popup menu with various actions. The current stable version is 0.19.5, with releases typically occurring as needed for bug fixes and feature enhancements, rather than on a strict schedule.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install pystray pillow"],"cli":null},"imports":["from pystray import Icon","from pystray import Menu, MenuItem","from PIL import Image, ImageDraw"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pystray\nfrom PIL import Image, ImageDraw\nimport os\n\ndef create_image(width, height, color1, color2):\n    # Generate a simple image for the icon\n    image = Image.new('RGB', (width, height), color1)\n    dc = ImageDraw.Draw(image)\n    dc.rectangle((width // 2, 0, width, height // 2), fill=color2)\n    dc.rectangle((0, height // 2, width // 2, height), fill=color2)\n    return image\n\ndef quit_action(icon, item):\n    icon.stop()\n\ndef show_message(icon, item):\n    print(\"Hello from the tray icon!\")\n\n# Create an image for the icon\nicon_image = create_image(64, 64, 'black', 'white')\n\n# Define the menu\nmenu = (\n    pystray.MenuItem('Say Hello', show_message),\n    pystray.MenuItem('Quit', quit_action)\n)\n\n# Create and run the icon\nicon = pystray.Icon('my_app_name', icon_image, 'My Awesome App', menu)\n\n# For simple, blocking execution, use icon.run()\n# For integration with other GUI frameworks, consider icon.run_detached() in a separate thread.\n# In this example, we'll use run() for simplicity.\nprint(\"pystray icon is running. Right-click for menu, or click 'Quit' to exit.\")\nicon.run()","lang":"python","description":"This quickstart demonstrates how to create a basic system tray icon with a custom image and a context menu. It defines functions for menu actions and runs the icon in a blocking loop. For integration with other GUI frameworks, `run_detached()` or threading should be considered.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"0.19.5","pypi_latest":"0.19.5","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.3,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pystray","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"39.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pystray","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.4,"import_time_s":null,"mem_mb":null,"disk_size":"40M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pystray","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"41.9M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pystray","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.3,"import_time_s":null,"mem_mb":null,"disk_size":"43M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pystray","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"33.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pystray","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.1,"import_time_s":null,"mem_mb":null,"disk_size":"35M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pystray","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"33.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pystray","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.2,"import_time_s":null,"mem_mb":null,"disk_size":"34M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pystray","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"36.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pystray","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.7,"import_time_s":null,"mem_mb":null,"disk_size":"38M"}]}}