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):
- super(TestWidget, self).__init__(parent)
- self.checkInstances()
- 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 name == 'myID':
- print 'found other instance: %s %s' % (widget, type(widget))
- if self is not widget:
- print 'closing other instance'
- else:
- print 'found myself'
- nukescripts.registerWidgetAsPanel('TestWidget', 'test widget', 'myID')
Advertisement
Add Comment
Please, Sign In to add comment