pywinrt / python-winsdk

Python package with bindings for Windows SDK
https://python-winsdk.readthedocs.io
MIT License
77 stars 8 forks source link

Notifications Not Working #10

Closed EpicCodeWizard closed 2 years ago

EpicCodeWizard commented 2 years ago

I have the following code sample (without the imports):

toastNotifier = ToastNotificationManager.create_toast_notifier("C:\Python38\python.exe")
notificationToSend = ToastNotification(xDoc)
import datetime
notificationToSend.expiration_time = datetime.datetime.now()

When I execute the code, I receive this error:

Traceback (most recent call last):
  File "████████", line 297, in <module>
    notificationToSend.expiration_time = datetime.datetime.now()
OSError: [WinError -2147024809] The parameter is incorrect

What am I doing wrong/How do I fix this?

dlech commented 2 years ago

I think the current implementation of WinRT date/time just uses ints. It would be nice if it was compatible with Python datetime though.

dlech commented 2 years ago

datetime conversion was added in v1.0.0b6

dlech commented 2 years ago

The windows APIs I timezone aware, so it is recommend to use datetime.now(timezone.utc) and avoid "naive" datetime object (see https://docs.python.org/3/library/datetime.html).