Cross-platform tray icons and a tkinter app base for small GUIs.
Project description
sevaht-gui
Small cross-platform GUI building blocks: a system-tray icon and a tkinter application base, shared across Sevaht desktop tools.
Tray icon
create_tray_icon returns a single TrayIcon interface backed by the right
implementation for the platform:
- Windows — pystray.
- Linux — a
StatusNotifierItem(D-Bus) item when a usable SNI host is present (KDE/GNOME, Wayland, or fluxbox withsnixembed), falling back to a self-contained XEmbed icon on bare X11 window managers with no SNI host.
The feature model is deliberately small: a default activate action (left-click, and the default menu item where a menu is available) and a quit action. Backends that can show a menu (pystray, SNI) offer both on right-click; the menu-less XEmbed backend maps right-click straight to quit.
The icon is any IconSource — a prepared PIL.Image, a path to an image
file (both static; the common case), or a renderer Callable[[int], Image]
for apps that draw their own artwork. The tooltip and the icon can be changed
live (set_icon accepts any IconSource), so an app can reflect state either
by swapping prepared images or by re-rendering.
macOS is intentionally unsupported: a real menu-bar item there needs a single main-thread Cocoa loop shared with tk (custom PyObjC), which the threaded model used here cannot provide.
TkApp
TkApp owns a tkinter.Tk root and runs its mainloop() on the main thread,
running the tray icon's own event loop on a worker thread. Work originating off
the UI thread (e.g. tray menu callbacks) is marshalled back with
run_on_ui_thread / call_on_ui_thread. show() / hide() and the
run(start_hidden=...) flag manage window visibility (all thread-safe), and
set_window_icon accepts the same IconSource as the tray.
from sevaht_gui import TkApp, create_tray_icon
app = TkApp()
app.root.title("Example")
app.set_window_icon("icon.png") # static file; or a PIL image / renderer
icon = create_tray_icon(
"example",
"Example",
"icon.png", # any IconSource: path, PIL image, or renderer
on_activate=app.show,
on_quit=app.stop,
)
app.run(icon, start_hidden=True) # only the tray shows until activated
The library manages the tray lifecycle, window visibility, and threading; choosing and (re)drawing the artwork is left to the application.
Documentation
Full documentation lives in docs/ and is published to GitHub Pages:
https://sevaht.github.io/sevaht-gui/.
Building the docs locally
$ uv run --group docs sphinx-build -b html docs docs/_build/html
Then open docs/_build/html/index.html. (Publishing to GitHub Pages requires
enabling Pages with the "GitHub Actions" source in the repository settings.)
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 Distribution
Built Distribution
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 sevaht_gui-1.0.0.tar.gz.
File metadata
- Download URL: sevaht_gui-1.0.0.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59342c7fce74ccecb593a2ed954585f36d4a11c12d82d178ef21d80a84275819
|
|
| MD5 |
279241b7a5f881dcd0d8f53a17ce2531
|
|
| BLAKE2b-256 |
c319b2b9780ded3b48304f433943eee9ef6a28ffa3fb1f2c602adb411bef90fc
|
Provenance
The following attestation bundles were made for sevaht_gui-1.0.0.tar.gz:
Publisher:
release.yml on sevaht/sevaht-gui
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sevaht_gui-1.0.0.tar.gz -
Subject digest:
59342c7fce74ccecb593a2ed954585f36d4a11c12d82d178ef21d80a84275819 - Sigstore transparency entry: 1935156658
- Sigstore integration time:
-
Permalink:
sevaht/sevaht-gui@6f80129559acc0387fdcf73c61505507958e547c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/sevaht
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f80129559acc0387fdcf73c61505507958e547c -
Trigger Event:
push
-
Statement type:
File details
Details for the file sevaht_gui-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sevaht_gui-1.0.0-py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75488fecc6e60bd08043a3617a85b6b6d97a6d8e25b33800b2bb5d7acbc0dd1e
|
|
| MD5 |
5dfbf296df411c8773488ca68c807ef4
|
|
| BLAKE2b-256 |
e4ef4ad8a019678faa1804212a453aa89307f9c61b8e7eb10d9645c62975d51a
|
Provenance
The following attestation bundles were made for sevaht_gui-1.0.0-py3-none-any.whl:
Publisher:
release.yml on sevaht/sevaht-gui
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sevaht_gui-1.0.0-py3-none-any.whl -
Subject digest:
75488fecc6e60bd08043a3617a85b6b6d97a6d8e25b33800b2bb5d7acbc0dd1e - Sigstore transparency entry: 1935156746
- Sigstore integration time:
-
Permalink:
sevaht/sevaht-gui@6f80129559acc0387fdcf73c61505507958e547c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/sevaht
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f80129559acc0387fdcf73c61505507958e547c -
Trigger Event:
push
-
Statement type: