Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Python 3.11 #112

Open
dshemetov opened this issue Nov 18, 2022 · 16 comments · May be fixed by #115
Open

Error in Python 3.11 #112

dshemetov opened this issue Nov 18, 2022 · 16 comments · May be fixed by #115

Comments

@dshemetov
Copy link

dshemetov commented Nov 18, 2022

A somewhat arcane error message after showing a toast in Python 3.11:

from win10toast import ToastNotifier
t = ToastNotifier()
>>> t.show_toast("hello")
WNDPROC return value cannot be converted to LRESULT
TypeError: WPARAM is simple, so must be an int object (got NoneType)
@tannnxr
Copy link

tannnxr commented Nov 27, 2022

It doesn't seem to break anything. It shows up for me after the duration ends, and the toast goes away.

https://i.imgur.com/qMZ1dvu.png

def notify():
    toaster = ToastNotifier()
    try:
        toaster.show_toast("Screenshot", "Screenshot saved to images folder", duration=5)
    except TypeError:
        pass
    print("Screenshot saved!")

@JasonMorris1
Copy link

I'm also getting the same error.

@M463
Copy link

M463 commented Dec 5, 2022

Same here.
Can be reproduced using the "official test program" at [..]\Python311\Lib\site-packages\win10toast\_main__.py_.
I've also tested this example which produces the same error message.
It looks like the TypeError is handled somewhere inside the win32api module with the printed message and not propagated further, hence placing the call to .show_toast() in a try-except block doesn't change the finding.

@ndonkoHenri
Copy link

Same here!

@LxHTT
Copy link

LxHTT commented Jan 7, 2023

Same here.

@mukibulh
Copy link

mukibulh commented Mar 4, 2023

getting the same error

@Xuangeaha
Copy link

Xuangeaha commented May 29, 2023

Same here on Win11 22H2 22621.1825 on Python 3.11.1.

from win10toast import ToastNotifier

......
t.show_toast(title=_title, msg=_msg, duration=15)

@FrigonTech
Copy link

Same here

@OHIO-MAN
Copy link

Same here
Is there any solution for this issue?

@LxHTT
Copy link

LxHTT commented Jul 11, 2023

Hi there,
I found a wonderful module to solve this problem. Use the following command to install it:
pip install win11toast
It seems to be OK to use win11toast instead of win10toast.
For more information, go to
https://pypi.org/project/win11toast/ .
You can also view it on GitHub: https://github.com/GitHub30/win11toast

Or you can also handle the TypeError of win10toast with a try-exceptblock.

(I’m sorry but I’m a 16-year-old student from a secondary school in China. There may be some grammatical errors in my reply.)

Hope this can help you all.

@itachi1010
Copy link

to fix the issue, simple got to the init.py file of win10toast in you virtual environment, and adjust the return value of the "on_destroy" function, replace it with this '
def on_destroy(self, hwnd, msg, wparam, lparam):
"""Clean after notification ended.

    :hwnd:
    :msg:
    :wparam:
    :lparam:
    """
    nid = (self.hwnd, 0)
    Shell_NotifyIcon(NIM_DELETE, nid)
    PostQuitMessage(0)

    return 0'

and you're good. I'll fork the project and make the changes then i'll link it in a future edit.

@itachi1010
Copy link

itachi1010 commented Jul 25, 2023

Same here Is there any solution for this issue?

to fix the issue, simple go to the init.py file of win10toast in you virtual environment, and adjust the return value of the "on_destroy" function, replace it with this '
def on_destroy(self, hwnd, msg, wparam, lparam):
"""Clean after notification ended.

    :hwnd:
    :msg:
    :wparam:
    :lparam:
    """
    nid = (self.hwnd, 0)
    Shell_NotifyIcon(NIM_DELETE, nid)
    PostQuitMessage(0)

    return 0'

and you're good. I'll fork the project and make the changes then i'll link it in a future edit.

@SaezMD
Copy link

SaezMD commented Aug 31, 2023

nid = (self.hwnd, 0)
Shell_NotifyIcon(NIM_DELETE, nid)
PostQuitMessage(0)

return 0'

Than you.
I have the last line like:
return 0'

@ashimgaev
Copy link

ashimgaev commented Sep 5, 2023

Did anyone try to create own class which is derived from ToastNotifier like:

class MyToastNotifier(ToastNotifier):
    def __init__(self):
        super().__init__()

    def on_destroy(self, hwnd, msg, wparam, lparam):
        super().on_destroy(hwnd, msg, wparam, lparam)
        return 0

this seems work for me.

@itachi1010
Copy link

A somewhat arcane error message after showing a toast in Python 3.11:

from win10toast import ToastNotifier
t = ToastNotifier()
>>> t.show_toast("hello")
WNDPROC return value cannot be converted to LRESULT
TypeError: WPARAM is simple, so must be an int object (got NoneType)

can you share the script you are using?

@UserJoo9
Copy link

Solution is easy.. just disable (Do not disturb) mode🙂
i faced same issue and fix it with this way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet