Reputation: 31
I am trying to create a nuke pane that I can call the same way the embedded panes are called. So far, I am able to see it in the 'custom windows' menu, but when I press on the button, the panel shows up empty.
I know the code is working because when I copy/paste it in the script editor, it works as desired, but I am probably missing some function that calls for my pane to be populated.
I am using QtWidgets, and this is my reduced code:
class NukePanel_AssetManager(QtWidgets.QWidget):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
self.setLayout(QtWidgets.QVBoxLayout())
myTable = QtWidgets.QTableWidget()
# all my functions and the things I am creating #
self.layout().addWidget(myTable)
pane = nuke.getPaneFor('Properties.1')
panels.registerWidgetAsPanel('NukePanel_AssetManager', 'Asset Manager', 'uk.co.thefoundry.NukePanel_AssetManager', True).addToPane(pane)
What am I missing?
Upvotes: 1
Views: 1776
Reputation: 31
This solved it!!
import nukescripts
import myPanelScript
pathToClass='myPanelScript.NukePanel_AssetManager' #the full python path to your panel
HRName='Asset Manager' #the Human-readable name you want for your panel
regName='NukePanel.AssetManager' #the internal registered name for this panel (used for saving and loading layouts)
nukescripts.panels.registerWidgetAsPanel(pathToClass, HRName, regName, True).addToPane(nuke.getPaneFor('Properties.1'))
Thank you all for your answers, as this would have not been possible for me without your inputs!!
Upvotes: 0
Reputation: 58563
The simplest way to have a regular modal pane in Nuke GUI is the following one:
import nuke
pane = nuke.Panel('Set number of Blur nodes')
pane.addSingleLineInput('Number of Blur nodes', '')
pane.show()
someInput = pane.value('Number of Blur nodes')
if someInput <= "0":
nuke.message('ERROR\nSet a number between 1 and 3')
elif someInput >= "4":
nuke.message('ERROR\nSet a number between 1 and 3')
elif "1" <= someInput <= "3":
nuke.message('number of Blur nodes: ' + someInput)
for _ in list(range(1, int(someInput[0]) + 1)):
nuke.createNode('Blur', inpanel = False)
Of course, you often want a non-modal panes, like depicted on a picture:
import nuke
import nukescripts
class Panes:
def createPane(self):
pythonPanel = nukescripts.PythonPanel('Keying Panel')
knob = nuke.Keyer_Knob('keyer', 'range')
knob.setValue( [0.0, 0.075, 0.5, 1.0] )
pythonPanel.addKnob(knob)
pythonPanel.addToPane()
return self
Panes().createPane()
Upvotes: 0
Reputation: 373
It probably has to do with where the panel is being defined. Since the first argument in registerWidgetAsPanel
is a string-representation of the name of the panel class (so weird), it works in the script panel (because it is defined right there), but not when you're loading it via init (because it is actually being defined in your module). If your module is named MyPanels
:
from nukescripts.panels import registerWidgetAsPanel
pathToClass='MyPanels.NukePanel_AssetManager' #the full python path to your panel
HRName='Asset Manager' #the Human-readable name you want for your panel
regName='NukePanel.AssetManager' #the internal registered name for this panel (used for saving and loading layouts)
registerWidgetAsPanel(pathToClass, HRName, regName)
Nuke has some some strange and inconsistent module importing; if you still have trouble, try adding your panel/module as a variable under the nuke module, which is available everywhere:
import nuke
from MyPanels import NukePanel_AssetManager
nuke.NukePanel_AssetManager=NukePanel_AssetManager
Hacky, but has helped me out a lot in the past!
Upvotes: 1