Comments (8)
Also looking for this feature! There is a duration setting in the win API. I will make a pr within this week if there is no response.
from windows-10-toast-notifications.
This has been requested in issue #15 with the intention of being implemented but would love to see this supported.
from windows-10-toast-notifications.
I think it's precise name is "Windows Action Center" if that helps.
from windows-10-toast-notifications.
I tried to not call the DestroyWindow function to stay in the "Windows Action Center", it seems to be no problems.
from windows-10-toast-notifications.
@jithurjacob Along the lines of what @usradd said, I think the best solution would be to change the code so that if you set duration=0 then the notification never closes.
from windows-10-toast-notifications.
duration = None worked for me .
from windows-10-toast-notifications.
Set "duration = None" is easy, but it will raise an error, and you will fail to call the function "show_toast()" again.
In fact, you can just comment line 153 in __init__.py
, and the problem can be solved.
Function "on_destroy()" will be like:
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 None
Or you can overwrite the function "on_destroy()". For example,
from win10toast import ToastNotifier
class MyToastNotifier(ToastNotifier):
def on_destroy(self, hwnd, msg, wparam, lparam):
pass
toaster = MyToastNotifier()
toaster.show_toast("Test", "Hello world!", threaded=True)
from windows-10-toast-notifications.
@Arsennnic Just try catch the exception will do the job as well :)
from win10toast import ToastNotifier
toaster = ToastNotifier()
try:
toaster.show_toast("Test", "Hello world!", duration=None)
except TypeError:
pass
Or simply let the thread die
toaster.show_toast("Test", "Hello world!", duration=None, threaded=True)
One question for people, taking this kind of approach means hijacking the line sleep(duration)
and prevent DestroyWindow(self.hwnd)
from executing.
But UnregisterClass(self.wc.lpszClassName, None)
will also not executed as well. Is it going to raise any problem if the notification is not unregistered? Or does unregistering means removing it from that Action Center?
from windows-10-toast-notifications.
Related Issues (20)
- Does this still work with Windows 11? HOT 4
- Toast-Notifications do not appear while chrome is on full screen mode. HOT 1
- How do I change the author of a notification?
- Cannot install pypiwin32 dependency on Linux HOT 1
- .show_toast() breaks PySimpleGUI and PyMsgBox
- Error in Python 3.11 HOT 16
- Maintain Notification
- Cannot install this module on python 3.12.0a2 HOT 3
- ERROR + FIX: WNDPROC return value cannot be converted to LRESULT TypeError: WPARAM is simple, so must be an int object (got NoneType) HOT 1
- Is it possible to change the sound effect used, or silence it?
- Error when explorer.exe is not working
- Exception: 'ToastNotifier' object has no attribute 'classAtom'
- arabic text
- Arabic text HOT 1
- I have a valid ICO but it wont load HOT 6
- Keep notification after excecution HOT 4
- Tkinter crash after use Toast HOT 2
- Windows 10 - Toasts stopped working HOT 8
- win10toast Breaks with pyinstaller
- Notification closing other python-based systray applications
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from windows-10-toast-notifications.