Last active
December 26, 2015 09:39
-
-
Save dbr/7131354 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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