Skip to content

gh-157749: Add tkinter.systray.NotificationHandler - #157760

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:systray-logging-handler
Open

serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:systray-logging-handler

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Add the NotificationHandler class to tkinter.systray -- a logging handler which shows log records as desktop notifications using the tk sysnotify command.

The title of the notification is the title argument, or the level name of the record by default. The message is the record formatted by the handler's formatter. The master window is used to send notifications; by default the default root window is looked up when a record is emitted, so the handler can be created before the root window. Errors are reported via handleError().

The test which sends a real notification is in SysTrayIconTest, so that all real notifications in a test process are sent from the same Tcl interpreter: on X11 with libnotify, Tk crashes or hangs when tk sysnotify is called after the interpreter which sent the previous notification was deleted (Tk unloads and reloads libnotify, and GLib cannot re-register its types). This is a Tk bug which will be reported separately.

🤖 Generated with Claude Code

A logging handler which shows log records as desktop notifications
using the "tk sysnotify" command.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34638105 | 📁 Comparing 7c93f77 against main (c0bc6fa)

  🔍 Preview build  

3 files changed
± library/tkinter.systray.html
± whatsnew/3.16.html
± whatsnew/changelog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant