I'd like to create a python script that sends me a windows toast notification and gives me two buttons, one to postpone, and one to start a backup (powershell script).
I tried multiple libraries, like winotify, win10toast, but settled on win11toast.
def on_postpone():
print("Postponed")
print(f"starting Backup notification")
ps_script = os.path.join(user_folder, 'Pictures', 'Backup_Starter.ps1')
buttons = [
{'activationType': 'protocol', 'arguments': f'{ps_script}', 'content': 'Start Backup'},
{'activationType': 'protocol', 'arguments':'', 'content': 'Postpone Backup'}
]
# send toast
toast(
"Script Ready to Start",
f"Click 'Start Script' to start, or 'Postpone' to postpone the Backup.",
duration="long",
buttons=buttons,
audio='ms-winsoundevent:Notification.Looping.Alarm'
)
# if Nothing clicked
print("Postponing the script...")
on_postpone()
While this kinda works, I cannot find a way to make the Start Backup button start the script, it does just open in notepad and also I cannot find a way to execute on_postpone always, except it there was a click on Start Backup.
Package used: https://pypi.org/project/win11toast/