python / python/cpython

Add tkinter.systray.NotificationHandler — a logging handler which shows log records as desktop notifications

Ouverte
#157,749 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

stdlib topic-tkinter type-feature
Langage dominant
Python
Étoiles
77.2k
Forks
35.9k
Métriques de merge des PR
Métriques de PR en attente

Description

Feature or enhancement

The tkinter.systray module (gh-153259) wraps the tk sysnotify command in the notify() function. A natural application of desktop notifications is showing warnings and errors reported via the logging module: a GUI application usually has no console, and a message box for every error is too intrusive.

I propose to add the NotificationHandler class to tkinter.systray. It formats the record with the handler's formatter and sends it as a notification. The title of the notification is the title argument, or the level name of the record (e.g. WARNING) by default. The master argument is the Tk window 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. Failures are reported via handleError(), as usual for logging handlers.

import logging
import tkinter
from tkinter.systray import NotificationHandler

root = tkinter.Tk()
handler = NotificationHandler('My application')
handler.setLevel(logging.WARNING)
logging.getLogger().addHandler(handler)

The handler belongs to tkinter.systray rather than logging.handlers because it is specific to Tk applications: it needs a Tk root window and follows tkinter's rules for the default root and for calls from other threads. logging.handlers should not depend on an optional GUI package.

Linked PRs
  • gh-157760

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par le module tkinter.systray existant et sa fonction notify(), puis examinez la PR liée gh-157760 avant d’effectuer quoi que ce soit. Le résultat demandé est un NotificationHandler qui formate les enregistrements, utilise le titre ou le nom du niveau, résout le master Tk comme décrit et signale les échecs via handleError() ; aucun fichier de test n’est nommé.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
desktop
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.