Metadata-Version: 2.4
Name: bettersystray
Version: 0.2.0
Summary: Windows only. Thread-safe system tray icons with animation and dynamic menus.
Keywords: systray,tray,notification area,windows,icon
License-Expression: MIT
License-File: LICENSE
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Dist: pillow>=9.1
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# bettersystray

Windows only. Thread-safe system tray icons for Windows 10 and later.

- Every method is safe to call from any thread
- Animated icons
- Right-click menus that are rebuilt on every click, with check marks, disabled items and submenus
- Callbacks run on a worker thread, so slow callbacks never freeze the icon
- Sharp icons on high DPI screens, and the icon comes back if Explorer restarts

## Install

```
pip install bettersystray
```

## Usage

```python
from PIL import Image

from bettersystray import BetterSysTray, MenuItem, MenuSeparator

tray = BetterSysTray(
    Image.open("icon.png"),
    "My app",
    lambda: [
        MenuItem(label="Hello", callback=lambda: print("Hello")),
        MenuSeparator(),
        MenuItem(label="Quit", callback=tray.stop),
    ],
    click_handler=lambda: print("Clicked"),
)
tray.start()
```

`start()` returns right away. The process stays alive until `stop()` is called.

Change the tray at any time, from any thread, with `update()`. Only the values you pass change, and values equal to the current ones are skipped:

```python
tray.update(title="New tooltip")
tray.update(icon=image)
tray.update(icon=[frame1, frame2, frame3])  # animates at the interval given to BetterSysTray
tray.update(icon=[frame1, frame2, frame3], interval=0.05)
tray.update(interval=0.2)  # changes the speed of the current animation
```

An icon counts as unchanged when you pass the same image objects again. To show changes made to an image in place, pass a copy, such as `image.copy()`.

## Demo

`examples/example.py` is an interactive console demo of every feature:

```
python examples/example.py
```

## License

MIT
