From 6758e3870a8767ca2ba152a29bcc7b57db8e48c7 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 24 Aug 2016 14:16:02 -0700 Subject: [PATCH] Slight improvement for the impl of the Borg design pattern. --- wx/lib/inspection.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wx/lib/inspection.py b/wx/lib/inspection.py index b7d2e846..c560e801 100644 --- a/wx/lib/inspection.py +++ b/wx/lib/inspection.py @@ -18,8 +18,8 @@ # to provide Hot-Key access to the inspection tool. """ -This modules provides the :class:`~lib.inspection.InspectionTool` and everything else needed to -provide the Widget Inspection Tool (WIT). +This modules provides the :class:`~wx.lib.inspection.InspectionTool` and +everything else needed to provide the Widget Inspection Tool (WIT). """ @@ -45,12 +45,18 @@ class InspectionTool: # instances of this class are actually using the same set of # instance data. See # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531 - __shared_state = {} + __shared_state = None + def __init__(self): - self.__dict__ = self.__shared_state + if not InspectionTool.__shared_state: + InspectionTool.__shared_state = self.__dict__ + else: + self.__dict__ = InspectionTool.__shared_state + if not hasattr(self, 'initialized'): self.initialized = False + def Init(self, pos=wx.DefaultPosition, size=wx.Size(850,700), config=None, locals=None, app=None): """