[wxPython-users] Re: Problem with SingleInstanceChecker with Windows XP and wxPython 2.6.3.2

Robin Dunn robin at alldunn.com
Mon Jun 12 12:07:52 PDT 2006


Pierre Rouleau wrote:
> Robin Dunn wrote:

>> You need to save a reference to the wx.SingleInstanceChecker 
>> reference, otherwise it will be destroyed when the __ini__ method 
>> exits.  I've updated the code sample in the wiki.
>>
> 
> Yep, the saved reference, say self.instance, solves the problem.  But I 
> don't understand why.  Is IsAnotherRunning() looking into its instance 
> dictionnary for an instance of wx.SingleInstanceChecker object?

A lock file (or something equivalent depending on platform) is created 
when the wx.SingleInstanceChecker object is created, and the lock is 
removed when it is destroyed.  So you want to make sure that the object 
lasts as long as the app does.

> 
> And Robin, thanks for updating the wiki page, but there is another 
> problem on that page.  Line 12 is a call to self.instance.Create() but 
> that call is superfluous as it raises an wx._core.PyAssertionError 
> stating that wxSingleInstanceChecker::Create() is called twice.

I wondered about that.  Thanks.

> 
> Is there any situation where we can call 
> wx.SingleInstanceChecker.Create().  I don't see one right. In C++ maybe 
> because you can call the default constructor. But I can't see one reason 
> why one would need to call Create() in Python.
> 

You're right that there probably wouldn't ever be a need for it, but 
there is a wx.PreSingleInstanceChecker constructor that will call the 
default C++ constructor.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list