No, not unique in the sense "oh, this app is a special snowflake", but unique in the sense "you can only run one copy of this application".
I tried googling for it and I always found the same answer, "use dbus, try to own the name, if it exists already, then a copy is already running".
What I could not find is one working example of this, or at least not something conveniently labeled "here is how you do a unique application using dbus and python".
So, here is how you do a unique application using dbus and python:
Supposing your application is called uRSSus (mine is):
session_bus = dbus.SessionBus()
# This is the second copy, make the first one show instead
# TODO: implement
except dbus.DBusException: # No other copy running
# This will 'take' the DBUS name
name = dbus.service.BusName("org.urssus.service", bus=session_bus)
# Now, start your app:
object = UrssusServer(window,name)
And that's it. No, it's not hard, but since the DBUS docs seem to be... rather they seem almost not to be sometimes, every little bit may help.
This is not really part of my PyQt by Example series but since it's a totally unrelated topic that would be impossible to connect to it, but is still a PyQt tutorial and shares the concept so, here it is.
No, this is not a post announcing I just wrote my first public python code. This is a post about my first public python code... from 1996!
In 1996, the soon-to-be-here year of the Linux desktop was fueled by one of the marquee open source applications of the time: LyX.
LyX was (is) a sort of word processor where you wrote and generated LaTeX which then produced whatever you used to print. But I am digressing: LyX was cool because it used one of the first goodfree graphical toolkits: XForms.
Ok, it was not really free, because you couldn't distribute patches.
And it was not all that good either, but we were comparing it with Motif, so it was much more free and much better than that monstrosity.
BTW: The latest release of XForms is from august of 2009.
At the time, a 25-year-old me was in love with Python 1.3. Here's how I described it:
Yes, Python 1.3. So, I wanted to use this C GUI toolkit used in this cool app, and this neat language I was learning and use them at the same time.
I ran (not walked) to my faithful Slackware 3.0 ELF in my 486DX2 PC and started hacking. In a weekend or so I had a working binding.
I even started writing the holy grail of desktop applications, a GUI version of Pine, using python and its IMAP module (python mailer, or PyM):
I released version 0.1 alpha in 1996, May 13 ... and a few months later Matthias Ettrich started KDE and I found Qt and never thought about XForms again.
Until this month.
For reasons that don't matter, I mentioned PyM in the PyAr mailing list the other day, and ... well, would pyxforms still work?
Why, pretty much, yeah!
I got the pyxforms-0.1-alpha sources from somewhere in the internet, installed XForms 1.0.92sp2 (yes, the latest release, from three months ago), of course I already had python 2.6.4 installed, added a setup.py, edited 10 lines of code and...
Yes, it works. You can get this 0.2 version (codename "Cthulhu was here") here just 13 years after 0.1.
No, I don't understand the weird rounded corners, or why the cursor looks weird and old when it's inside the window.
It's a REALLY small and fast toolkit, though.
Honestly, is it useful for ayone? Almost certainly not. Am I amazed something I wrote in 1996 still works? Oh, yeah I am.