Add tkinter.systray.NotificationHandler — a logging handler which shows log records as desktop notifications
Personne n'a encore pris cette issue.
- 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
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- 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