Cross-Platform Python3 Equivalent to notify-send

Chris Angelico rosuav at gmail.com
Sat Jul 27 08:47:47 EDT 2013


On Sat, Jul 27, 2013 at 1:22 PM, Devyn Collier Johnson
<devyncjohnson at gmail.com> wrote:
> That really sucks. I was hoping Python had some way of doing that. All that
> it needs to do is display a little box at one of the corners of the screen.
> I thought someone would have implemented something by now. Thank you anyway.

Despite the best efforts of a pretty talented core dev team, Python is
not yet capable of magic :) If you browse the python-dev archives,
you'll see how much of a nightmare cross-platform compatibility can be
(eg the recent discussion on cloexec and passing file descriptors to
subprocesses); often, what you might think (from a user's point of
view) is fairly trivial will turn out to be quite tricky.

That said, though, a lot of GUI toolkits will have a means for you to
highlight a window. In GTK, it's called "present" (as in, "Lord User,
may I present Sir Window and Mrs Window?"). There may be window
managers that don't support the feature (and there are certainly those
that let the user disable it, which you should respect), but AFAIK all
of them should at least accept the command.

http://www.pygtk.org/docs/pygtk/class-gtkwindow.html#method-gtkwindow--present

So your best bet may be to simply create yourself a small window, then
present it. On Windows XP, I think that'll flash the window in the
task bar, which is usually enough highlight. On my Debian Wheezy with
Xfce, it brings the window to the top of the Z-order, and optionally
moves it to the current workspace (user's option, NOT program's).

ChrisA



More information about the Python-list mailing list