python - PySimpleGui SystemTray.notify 持续时间参数
问题描述
我想使用 PySimpleGUIs SystemTray.notify 类方法发送 Windows 10 通知,该类方法具有特定的持续时间或在单击之前根本不会消失。
在文档中,您可以找到以下句子:“有控制淡入淡出、显示多长时间、Alpha 通道等的选项。请参阅本文档末尾的调用签名。”
但我在文档中找不到更多信息。
我试过(出乎意料)sg.SystemTray.notify('Notification Title', 'This is the notification message', duration=10)
它会返回notify() got an unexpected keyword argument 'duration'
有人知道如何设置持续时间等吗?
解决方案
参考系统托盘
以下示例显示方式,右键单击图标以显示菜单。
import PySimpleGUI as sg
menu_def = ['My_Menu', ['Notify', 'Show', 'Quit']]
tray = sg.SystemTray(menu=menu_def, data_base64=sg.EMOJI_BASE64_HAPPY_IDEA)
while True:
event = tray.read()
if event in (sg.WINDOW_CLOSED, 'Quit'):
break
elif event == 'Notify':
tray.notify("Notify", "You got this notify", fade_in_duration=50, display_duration_in_ms=1000, alpha=0.5)
elif event == 'Show':
tray.show_message("Message", "You got this message", time=(50, 1000))
tray.close()