Git Product home page Git Product logo

Comments (16)

LxHTT avatar LxHTT commented on September 21, 2024 9

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.

from windows-10-toast-notifications.

itachi1010 avatar itachi1010 commented on September 21, 2024 5

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.

from windows-10-toast-notifications.

tannnxr avatar tannnxr commented on September 21, 2024 2

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!")

from windows-10-toast-notifications.

JasonMorris1 avatar JasonMorris1 commented on September 21, 2024 1

I'm also getting the same error.

from windows-10-toast-notifications.

itachi1010 avatar itachi1010 commented on September 21, 2024 1

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.

from windows-10-toast-notifications.

M463 avatar M463 commented on September 21, 2024

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.

from windows-10-toast-notifications.

ndonkoHenri avatar ndonkoHenri commented on September 21, 2024

Same here!

from windows-10-toast-notifications.

LxHTT avatar LxHTT commented on September 21, 2024

Same here.

from windows-10-toast-notifications.

mukibulh avatar mukibulh commented on September 21, 2024

getting the same error

from windows-10-toast-notifications.

Xuangeaha avatar Xuangeaha commented on September 21, 2024

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)

from windows-10-toast-notifications.

FrigonTech avatar FrigonTech commented on September 21, 2024

Same here

from windows-10-toast-notifications.

OHIO-MAN avatar OHIO-MAN commented on September 21, 2024

Same here
Is there any solution for this issue?

from windows-10-toast-notifications.

SaezMD avatar SaezMD commented on September 21, 2024

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

return 0'

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

from windows-10-toast-notifications.

ashimgaev avatar ashimgaev commented on September 21, 2024

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.

from windows-10-toast-notifications.

itachi1010 avatar itachi1010 commented on September 21, 2024

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?

from windows-10-toast-notifications.

UserJoo9 avatar UserJoo9 commented on September 21, 2024

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

from windows-10-toast-notifications.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.