[PyQt] Singelton from QObject
Nahuel Defossé
nahueldefosse at yahoo.com.ar
Wed May 23 05:53:58 BST 2007
I saw in ActiveState page the folowing code to make a singleton:
class Borg:
__shared_state = {}
def __init__(self):
self.__dict__ = self.__shared_state
# and whatever else you want in your class -- that's all!
And in all Qt classes I customize via inheritance I do the folowing:
class MyClass(QSomeName):
def __init__(self):
QSomeName.__init__(self)
I want to make a config class that recives some signals, so I inhertit from
QObject. I did the folowing in the constructor...
def __init__(self):
if self.__shared_state == None:
QObject.__init__(self)
self.__dict__ = self.__shared_state
It seems to work, but I'm not sure. Have you ever tried to do something like
that?
Thanks
More information about the PyQt
mailing list