Skip to content

Error when calling toast with on_click param set to a lambda #53

@KugelMaster

Description

@KugelMaster

If you try this code and click on the notification:

win11toast.toast(
    title="Bug",
    on_click=lambda x: print("Toast clicked!")
)

You get the following exception:

Traceback (most recent call last):
  File "C:\Users\<path-to-file>\.venv\Lib\site-packages\win11toast.py", line 366, in <lambda>
    activated_future.set_result, on_click(activated_args(*args))
  File "C:\Users\<path-to-file>\.venv\Lib\site-packages\win11toast.py", line 169, in activated_args
    e.user_input[name]).get_string()) for name in e.user_input()])
TypeError: 'winrt._winrt_windows_foundation_collections.ValueSet' object is not callable

However, if you remove the brackets after the e.user_input variable in line 169 like this:

user_input = dict([(name, IPropertyValue._from(
    e.user_input[name]).get_string()) for name in e.user_input])

Then both the string version and the lambda version work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions