-
Notifications
You must be signed in to change notification settings - Fork 168
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
Added on-click callback feature #38
base: master
Are you sure you want to change the base?
Conversation
Great, this works perfectly for me! |
Is this going to be merged? @Charnelx could you give a bit more detail on this, sorry guys bit of a Python noob, I downloaded the changed file and replaced the old one in source, built from source (I think that worked correctly?) Just need some clarification on how to implement a click action to my toast notifications |
@JDogg1329 , don't know about merge, but you can get this from my own repo if needed. Example: def say_hello():
print('Hello!')
toast = ToastNotifier()
toast.show_toast( title="Notification", msg="Here comes the message",
icon_path=None, duration=5, threaded=False, callback_on_click=say_hello) In this case, if notification is clicked, |
Thanks @Charnelx ! So is it possible to pass an argument to the callback_on_click method? |
@JDogg1329 , nope, you can't pass the argument in a direct way...but you can do a trick like this: toast.show_toast( title="Notification", msg="Here comes the message",
icon_path=None, duration=5, threaded=False, callback_on_click=lambda: say_hello(arg)) |
@Charnelx Bro I have been trying some random stuff for a long time. Thanks for your help. Now I can die peacefully 🤣 |
@Charnelx I noticed that if user won't click on the notification, after 10 seconds (in windows 10) the message will be moved to "Action Center" (the notification area on the left side of the screen), and there I couldn't handle the user's click action. Thanks |
Enhancement of Added on-click callback feature jithurjacob#38. New code now supports parameters to be passed to callback function. Issue: When including parameters to callback function, the function gets executed before the notification. The intention of the on-click was to wait for user click the notification before execute the function def say_hello(): print('Hello!') toast = ToastNotifier() toast.show_toast( title="Notification", msg="Here comes the message", icon_path=None, duration=5, threaded=False, callback_on_click=say_hello(param)) With new code: def say_hello(**kwargs): print(kwargs.get('func_param1 ') + kwargs.get('func_param2 ')) toast = ToastNotifier() toast.show_toast( title="Notification", msg="Here comes the message", icon_path=None, duration=5, threaded=False, callback_on_click=say_hello, func_param1 = 'Hello', func_param2 = 'World' )
I've installed |
same for me. |
Fixes incompatibility with pip version 10 and above
Does this still work? I tried replacing my init.py contents with the contents from your file @Charnelx but the script was full of errors and said the callback_on_click was not an argument I could use. Sorry if I am doing something wrong, but I'm a noob |
@crappy-coder21 , just try to update your version using pip. |
@Charnelx Nice work ! |
this should be merged to master it is a very useful feature |
Anybody still having problems with the: I installed yesterday so it must be the latest version. What could i do wrong? |
Was it fixed? Because I still get the error |
now uses release from this pull request of win10toast: jithurjacob/Windows-10-Toast-Notifications#38
Will this ever be merged? Because I hope so. |
If anyone want's this feature and is using pipenv, the following command will update the package to the version with the
I couldn't get it to work using |
LGTM |
There is still same problem: TypeError: show_toast() got an unexpected keyword argument 'callback_on_click' |
Is it ever going to merge ? Its been 2 Years Now ! @Charnelx Please make a New pip Repo with Your Version 🙏 |
Hey Guys, this works perfectly, BUT: in my case the callback_on_click is executed instantly after this toast shows up. How can i make that the action only executes if I click it? cheers leon |
You are probably doing something like ...(callback_on_click=print('clicked')) when in reality, you wanna do ...(callback_on_click=lambda: print('clicked')) |
I'm doing as followed: ... callback_on_click=open_ticket(ticket_link) def open_ticket(url): In this case it's always executing the def open_ticket when the toast shows up |
What you are doing is essentially the same as... result = open_ticket(ticket_link)
...(click_on_callback=result) You are calling the function and assigning it's return value to the You instead need to pass in the function (not it's call resulting in a return value) as the ...(callback_on_click=lambda: open_ticket(ticket_link)) |
aaaah damn didn't thought about that tho. |
i feel dumb, but how do i install it???? |
help, im getting errors saying "the system could not find the file specified." |
@jellytoaster With this little information noone can help you. You will better off to ask on StackOverflow. GitHub issues is not a place to ask such questions. |
If you don't use |
Is there a fork that allows using |
If you're aiming to keep the notification persistent in the action centre |
I suppose you meant @jithurjacob instead of @jacobcolbert |
i believe he changed his name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it
I've a problem, I ran this code but the function trigger as soon as the toast appear on the screen. So click don't work. Do you have the same problem? (I would like to open a webpage whether I click on the toast) |
That's because you used a function call as the trigger instead of the function itself. |
@Charnelx I noticed that if user won't click on the notification, after 10 seconds (in windows 10) the message will be moved to "Action Center" (the notification area on the left side of the screen), and there I couldn't handle the user's click action. |
The library works well for me except on one point: I want my notification to stay in the action center if I don't click on it. So I set the duration parameter to None. However, after 10s, the notification disappear from the action center. It is strange because this functionality works well on the previous version (win10toast_persist). Does anyone had the same issue already ? |
This pull request will be merged and able when you do your pip install someday? |
Hi.
I added callback on click functionality discussed in this issue .
Implementation followed this comment plus my own code snippet for decorator/handler.
How it works - just add to
show_toast
method argument calledcallback_on_click
with callable as value.