Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Provides systray integration

Project Description

pystray Package Documentation

This library allows you to create a system tray icon.

Creating a system tray icon

In order to create a system tray icon, the class pystray.Icon is used:

import pystray

icon = pystray.Icon('test name')

In order for the icon to be displayed, we must provide an icon. This icon must be specified as a PIL.Image.Image:

from PIL import Image, ImageDraw

# Generate an image
image = Image.new('RGB', (width, height), color1)
dc = ImageDraw.Draw(image)
dc.rectangle((width // 2, 0, width, height // 2), fill=color2)
dc.rectangle((0, height // 2, width // 2, height), fill=color2)

icon.image = image

To ensure that your application runs on all platforms, you must then run the following code to show the icon:

def setup(icon):
    icon.visible = True

icon.run(setup)

The call to pystray.Icon.run() is blocking, and it must be performed from the main thread of the application. The reason for this is that the system tray icon implementation for OSX must be run from the main thread, and it requires the application runloop to be running. pystray.Icon.run() will start the runloop.

The code in setup() will be run in a separate thread once the system tray icon is ready. The icon does not wait for it to complete, so you may put any code that would follow the call to pystray.Icon.run() in it.

pystray.Icon.run() will not complete until ~pystray.Icon.stop() is called.

If you do not wish to support OSX, the above code can be replaced with the following:

icon.visible = True

Release Notes

v0.2 - Initial Release

  • Support for adding a system tray icon on Linux, Mac OSX and Windows.
Release History

Release History

History Node

0.14.3

History Node

0.14.2

History Node

0.14.1

History Node

0.14

History Node

0.13

History Node

0.12

History Node

0.11

History Node

0.10

History Node

0.9

History Node

0.8

History Node

0.7

History Node

0.6

History Node

0.5

History Node

0.4

History Node

0.3.5

History Node

0.3.4

History Node

0.3.3

History Node

0.3.2

History Node

0.3.1

History Node

0.3

This version
History Node

0.2

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pystray-0.2-py2-none-any.whl (231.5 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Mar 27, 2016
pystray-0.2-py3.5.egg (25.0 kB) Copy SHA256 Checksum SHA256 3.5 Egg Apr 19, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting