Open Wickscc opened 2 years ago
按钮(action)有activationType
这个参数,但是文档(尤其是对于非安装程序的)太少了,所以我暂时只将按钮用于关闭。
你的这个需求可以用选项菜单代替一下:
from winsdk_toast import Notifier, Toast
from winsdk_toast.event import EventArgsActivated, EventArgsDismissed, EventArgsFailed
def testToast():
# Step1. Create Notifier with applicationId
notifier = Notifier('MQTT 消息通知')
# Step2. Create Toast which contains the message to be shown
toast = Toast()
toast.add_text('第一行 1st line', hint_align='center', hint_style='caption')
toast.add_input('selection', id_='input01')
toast.add_selection(content='1', id_='selection_1')
toast.add_selection(content='2', id_='selection_2')
toast.add_selection(content='3', id_='selection_3')
toast.add_selection(content='4', id_='selection_4')
toast.add_action('确认')
# Step3. Show the Toast
notifier.show(toast, handle_activated=notifyActiveHandler, handle_dismissed=handle_dismissed)
def notifyActiveHandler(event_args_activated: EventArgsActivated):
print('activated')
print('inputs:', event_args_activated.inputs)
print('argument:', event_args_activated.argument)
def handle_dismissed(event_args_dismissed: EventArgsDismissed):
print('dismissed')
print('reason:', event_args_dismissed.reason)
如图所示, 点击了 1 2 3 4 过后 handle_activated 返回结果都是一样的