pystray icon indicating copy to clipboard operation
pystray copied to clipboard

Feature Suggestion: Action when Notification is Clicked

Open CesarPazzi opened this issue 4 years ago • 5 comments

I'm on Windows 10 20H2 19042.685 Python version Python 3.8.2

I just download and started using pystray and just a suggestion... It would be nice to execute a function when notification is clicked.

Something like:

icon.notify("Notification Text", title="Notification Title", MyFunction)

Or if you point me where to look in the code I would like to get my hands on and when I get something I will do a PR

CesarPazzi avatar Jan 11 '21 05:01 CesarPazzi

Thank you for your suggestion.

I am not certain whether this is supported by all backends, but you will find the relevant code for Windows here and for Linux here.

I will gladly help if you run into any issues!

moses-palmer avatar Jan 11 '21 18:01 moses-palmer

For Windows, it sounds easy to implement: https://stackoverflow.com/questions/59990706/how-to-capture-users-click-action-when-clicking-on-notifications

No idea how hard would it be to do for Linux. Also, this feature is a +1 from me, I could really use something like this.

DevilXD avatar Apr 02 '22 14:04 DevilXD

@DevilXD Were you able to implement this feature for any platform? IMO the feature can be implemented on some platforms only, and raise NotImplementedError on unsupported platforms.

sohang3112 avatar Sep 04 '23 11:09 sohang3112

@sohang3112 As I've mentioned in my message, Windows implementation should be possible, per that SO thread. I haven't been able to implement it anywhere myself, I merely pointed out that it should be possible to do so on Windows, relatively easily, by hooking up an additional window manager event to a function call. Again, no idea how it'd work on Linux or other platforms.

DevilXD avatar Sep 04 '23 18:09 DevilXD