Guest User

Untitled

a guest
Oct 23rd, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from PySide import QtGui
  2.  
  3. class TestWidget(QtGui.QLabel):
  4.     def __init__(self, parent=None):
  5.         super(TestWidget, self).__init__(parent)
  6.         self.checkInstances()
  7.         self.setObjectName('myID')
  8.         self.setText('only show me once')
  9.  
  10.     def checkInstances(self):
  11.         print 'new instance:', self
  12.         for widget in QtGui.QApplication.allWidgets():
  13.             name = widget.objectName()
  14.             if name == 'myID':
  15.                 print 'found other instance: %s %s' % (widget, type(widget))
  16.                 if self is not widget:
  17.                     print 'closing other instance'
  18.                 else:
  19.                     print 'found myself'
  20.  
  21. nukescripts.registerWidgetAsPanel('TestWidget', 'test widget', 'myID')
Advertisement
Add Comment
Please, Sign In to add comment