Add tkinter.systray.NotificationHandler — a logging handler which shows log records as desktop notifications
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece pelo módulo tkinter.systray existente e por sua função notify(), depois inspecione o PR vinculado gh-157760 antes de realizar qualquer trabalho. O resultado solicitado é um NotificationHandler que formate registros, use o título ou o nome do nível, resolva o master do Tk conforme descrito e reporte falhas por meio de handleError(); nenhum arquivo de teste é mencionado.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- desktop
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 25/100