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

Đang mở
#157,749 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
desktop

Hướng nghiên cứu

Bắt đầu với mô-đun tkinter.systray hiện có và hàm notify() của mô-đun đó, sau đó kiểm tra PR gh-157760 được liên kết trước khi thực hiện bất kỳ công việc nào. Kết quả được yêu cầu là một NotificationHandler có nhiệm vụ định dạng các bản ghi, sử dụng title hoặc tên level, phân giải Tk master như mô tả và báo cáo các lỗi thông qua handleError(); không có tệp kiểm thử nào được nêu tên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

stdlib topic-tkinter type-feature

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
Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
558

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python/cpython

Tất cả issue của python/cpython

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.