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 PyQt ) 167 168 import nuke 169 import PyQt4.QtCore as QtCore 170 import PyQt4.QtGui as QtGui 171 from nukescripts import panels 172 173 class NukeTestWindow(QtGui.QWidget): 174 def __init__(self, parent=None): 175 QtGui.QWidget.__init__(self, parent) 176 self.setLayout( QtGui.QVBoxLayout() ) 177 self.myTable = QtGui.QTableWidget( ) 178 self.myTable.header = ['Date', 'Files', 'Size', 'Path' ] 179 self.myTable.size = [ 75, 375, 85, 600 ] 180 self.layout().addWidget( self.myTable ) 181 182 nukescripts.registerWidgetAsPanel('NukeTestWindow', 'NukeTestWindow', 'uk.co.thefoundry.NukeTestWindow' ) 183 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 Jun 30 18:46:46 2017 | http://epydoc.sourceforge.net |