Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PySide import QtGui
- class TestWidget(QtGui.QLabel):
- def __init__(self, parent=None):
- self.checkInstances()
- super(TestWidget, self).__init__(parent)
- self.setObjectName('myID')
- self.setText('only show me once')
- def checkInstances(self):
- print 'new instance:', self
- for widget in QtGui.QApplication.allWidgets():
- name = widget.objectName()
- if type(widget) == type(self):
- print "instance already present"
- p = widget.parentWidget()
- while p:
- if p.parent() and isinstance(p.parent(), QtGui.QStackedWidget):
- p.parent().removeWidget(p)
- p = None
- else:
- p = p.parentWidget()
- nukescripts.registerWidgetAsPanel('TestWidget', 'test widget', 'myID')
Advertisement
Add Comment
Please, Sign In to add comment