Trees | Indices | Help |
|
---|
|
1 # Copyright (c) 2009 The Foundry Visionmongers Ltd. All Rights Reserved. 2 3 import sys 4 import nuke 5 import pyui 6 7 __panels = dict() 8 1113 del __panels[id]1416 try: 17 return __panels[id]() 18 except: 19 print "Can't restore panel '", id, "' because it hasn't been registered." 20 return None21 2426146 147 15528 pyui.Dialog.__init__( self, title, id, scrollable ) 29 self.__node = nuke.PanelNode() 30 self.__widget = None 31 self.__openTabGroups = 0 32 self.okButton = None 33 self.cancelButton = None 34 self._isModalDialog = False3537 nuke.addKnobChanged(PythonPanelKnobChanged, args = self, nodeClass = 'PanelNode', node = self.__node)3840 nuke.removeKnobChanged(PythonPanelKnobChanged, args = self, nodeClass = 'PanelNode', node = self.__node)4143 if type(knob) == nuke.BeginTabGroup_Knob: 44 self.__openTabGroups += 1 45 elif type(knob) == nuke.EndTabGroup_Knob: 46 self.__openTabGroups -= 1 47 elif type(knob) == nuke.Tab_Knob and self.__openTabGroups <= 0: 48 self.addKnob( nuke.BeginTabGroup_Knob() ) 49 50 self.__node.addKnob( knob ) 51 knob.setFlag( nuke.NO_UNDO | nuke.NO_ANIMATION )5254 if type(knob) == nuke.BeginTabGroup_Knob: 55 self.__openTabGroups -= 1 56 elif type(knob) == nuke.EndTabGroup_Knob: 57 self.__openTabGroups += 1 58 59 self.__node.removeKnob( knob )6062 return self.__node.knobs()63 6668 return self.__node.readKnobs( s )6971 self.knobChanged(knob) 72 if knob == self.okButton: 73 self.finishModalDialog( True ) 74 elif knob == self.cancelButton: 75 self.finishModalDialog( False )76 79 8385 self.finishModalDialog( True )8688 self.finishModalDialog( False )8991 while self.__openTabGroups > 0: 92 self.addKnob(nuke.EndTabGroup_Knob()) 93 if self.__widget == None: 94 self.__widget = self.__node.createWidget( self ) 95 self.add( self.__widget, 0, 0, 1, 3 )96 101 104106 self.__modalResult = None; 107 self._isModalDialog = True 108 if self.okButton == None: 109 self._makeOkCancelButton() 110 if defaultKnobText == "": 111 defaultKnobText = self.okButton.name() 112 self.showModal(defaultKnobText) 113 return self.__modalResult114116 while self.__openTabGroups > 0: 117 self.addKnob(nuke.EndTabGroup_Knob()) 118 self.okButton = nuke.Script_Knob( "OK" ) 119 self.addKnob( self.okButton ) 120 self.okButton.setFlag( nuke.STARTLINE ) 121 self.cancelButton = nuke.Script_Knob( "Cancel" ) 122 self.addKnob( self.cancelButton )123125 self.addCallback() 126 self.create() 127 super(PythonPanel, self).showModal(defaultKnobText) 128 self.removeCallback()129131 self.create() 132 if pane != None: 133 pane.add( self ) 134 elif nuke.thisPane() != None: 135 nuke.thisPane().add( self ) 136 self.addCallback() 137 return self138 142157 """registerWidgetAsPanel(widget, name, id, create) -> PythonPanel 158 159 Wraps and registers a widget to be used in a Nuke panel. 160 161 widget - should be a string of the class for the widget 162 name - is is the name as it will appear on the Pane menu 163 id - should the the unique ID for this widget panel 164 create - if this is set to true a new NukePanel will be returned that wraps this widget 165 166 Example ( using PySide2 ) 167 168 import nuke 169 from PySide2 import QtCore, QtWidgets 170 from nukescripts import panels 171 172 class NukeTestWindow( QtWidgets.QWidget ): 173 def __init__(self, parent=None): 174 QtWidgets.QWidget.__init__(self, parent) 175 self.setLayout( QtWidgets.QVBoxLayout() ) 176 177 self.myTable = QtWidgets.QTableWidget() 178 headers = ['Date', 'Files', 'Size', 'Path' ] 179 self.myTable.setColumnCount( len( headers ) ) 180 self.myTable.setHorizontalHeaderLabels( headers ) 181 self.layout().addWidget( self.myTable ) 182 183 nukescripts.registerWidgetAsPanel('NukeTestWindow', 'NukeTestWindow', 'uk.co.thefoundry.NukeTestWindow' ) 184 """ 185 186 187 class Panel( PythonPanel ): 188 189 def __init__(self, widget, name, id): 190 PythonPanel.__init__(self, name, id ) 191 self.customKnob = nuke.PyCustom_Knob( name, "", "__import__('nukescripts').panels.WidgetKnob(" + widget + ")" ) 192 self.addKnob( self.customKnob )193 194 def addPanel(): 195 return Panel( widget, name, id ).addToPane() 196 197 menu = nuke.menu('Pane') 198 menu.addCommand( name, addPanel) 199 registerPanel( id, addPanel ) 200 201 if ( create ): 202 return Panel( widget, name, id ) 203 else: 204 return None 205
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Feb 14 13:53:22 2020 | http://epydoc.sourceforge.net |