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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pystray-0.2-py3.5.egg.
File metadata
- Download URL: pystray-0.2-py3.5.egg
- Upload date:
- Size: 25.0 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e9c57a9ada9946672d5f64f78f33d49bf0c0d63435b91b92754fca5ca2e2054
|
|
| MD5 |
1f6b9719bd73724136ef99c56891599c
|
|
| BLAKE2b-256 |
fe3cbd6d8efbcc6053292fda91f7573faa6de9764cff846d37aba182aa6ee90f
|
File details
Details for the file pystray-0.2-py2-none-any.whl.
File metadata
- Download URL: pystray-0.2-py2-none-any.whl
- Upload date:
- Size: 231.5 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f4c34354988c61a7e2dbccabc78b3c6bb6bc5ab42b99e77ee353bc408982cde
|
|
| MD5 |
bc852269a2f6f3ca5a2609395afef93c
|
|
| BLAKE2b-256 |
e429b6a6ea2c6b3189ec7eff64955454747a7fa2e2b025609f66e92432068147
|