What you want is wx.SingleInstanceChecker.
http://wxwidgets.org/manuals/2.5.3/wx_wxsingleinstancechecker.html
Seems one can use it for an own 'singular' app, but cannot
check if an other app is running (e.g. before my app would
start it) - perhaps enough for the OP, but not enough for me.
It doesn't even seem to work (on WinXP):
In my App's __init__:
self.SIC = wx.SingleInstanceChecker('Lola')
# self.SIC.Create()
if self.SIC.IsAnotherRunning():
raise Exception('Lola runs already!')
The C docs tell me, I should create the SIC with a name (as I do) *or* without and then use Create with a name.
*** I can't create SIC without the name:
self.SIC = wx.SingleInstanceChecker()
File "C:\Programme\Python\lib\site-packages\wx-2.6-msw-unicode\wx\_misc.py", line 957, in __init__
newobj = _misc_.new_SingleInstanceChecker(*args, **kwargs)
TypeError: new_SingleInstanceChecker() takes at least 1 argument (0 given)
*** If I use the code above (without Create), it doesn't check (i.e. several same apps will open).
*** If I use an empty Create, I get:
self.SIC.Create()
File "C:\Programme\Python\lib\site-packages\wx-2.6-msw-unicode\wx\_misc.py", line 969, in Create
return _misc_.SingleInstanceChecker_Create(*args, **kwargs)
TypeError: SingleInstanceChecker_Create() takes at least 2 arguments (1 given)
*** If I try to use the name twice, I get:
self.SIC.Create(self.name)
File "C:\Programme\Python\lib\site-packages\wx-2.6-msw-unicode\wx\_misc.py", line 969, in Create
return _misc_.SingleInstanceChecker_Create(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "!m_impl" failed in ..\..\src\msw\snglinst.cpp(110): calling wxSingleInstanceChecker::Create() twice?
All in all, this feature seems useless.
Best regards,
Henning Hraban Ramm
Südkurier Medienhaus / MediaPro
Support/Admin/Development Dept.