A unique instance of Python GUI program

akineko akineko at gmail.com
Wed Sep 17 23:45:30 EDT 2008


Again, thank you for many postings to my question.
I have reviewed solutions provided.
Well, I like the named Mutex solution under Windows.
That is a clean and straight-forward approach to the challenge.
(I cannot believe that I'm saying good thing about Windows ;-) )

Unfortunately, I'm living in Unix realm ;-)

None of solutions for Unix are appealing to me.
But they must be "the" solution for the challenge as well-established
software uses those solutions.

Now, I'm wondering.
As my program is a GUI (Tkinter) software.
Is it possible to set a known value to X11 or Tk property through
Tkinter so that another instance of the program can check if such
property is set?

Of course, I know this scheme has a flaw. If one instance uses another
logical display, then such property is probably not shared.
But for my usage, it is logically possible but not likely.

I checked my Tkinter book and found the following function.
winfo_interps(displayof=0)

This returns a list of all Tk-based applications currently running on
the display.

When I tried, I got the following:
>>> root.winfo_interps()
('tk #3', 'tk #2', 'tk')

But I couldn't find a way to set a specific name to the Tcl
interpreter.

As I'm not an expert of Tcl/Tk and X11, I probably overlooked other
functions that may do what I need.

Any comments, suggestions on this?
Maybe this can provide a platform independent way to ensure that only
single instance is running.

Thank you for your attention.

Best reagrds,
Aki Niimura



More information about the Python-list mailing list