Skip to content

Instantly share code, notes, and snippets.

@dbr
Last active December 26, 2015 09:39
Show Gist options
  • Save dbr/7131354 to your computer and use it in GitHub Desktop.
Save dbr/7131354 to your computer and use it in GitHub Desktop.
from PySide import QtGui
_testwidget_instance = None
class TestWidget(QtGui.QLabel):
def __init__(self, parent=None):
super(TestWidget, self).__init__(parent)
# There can be only one.. assuming this works..
global _testwidget_instance
if _testwidget_instance is None:
_testwidget_instance = self
else:
# Ideally the panel would close itself here, but
# can't work out how to access the PythonPanel
# instance from here (nuke.thisPane is close,
# but nope)
nuke.message("Panel already open, stopit")
self.setText('Was already open')
return
# Regular panel'y stuff
self.setObjectName('myID')
self.setText('only show me once')
def hideEvent(self, evt):
global _testwidget_instance
_testwidget_instance = None
nukescripts.registerWidgetAsPanel('TestWidget', 'test widget', 'myID')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment