Looks like you need to feed the custom python knob a QWidget instance.
So with the below code in your plugin path, you can just add a custom python knob to your gizmo and instantiate the widget in there simply with:
MyWidget()

This will create a new instance every time though, so you will be responsible for keeping track of the widget values between panel close/open cycles. Most likely you will want to connect the values to internal node values anyway, so that should take care of it, I haven't tried it myself yet.


class MyWidget(QtGui.QWidget):

def __init__(self):

super(self.__class__, self).__init__()

self.node = nuke.thisNode()

layout = QtGui.QHBoxLayout()

layout.setAlignment(QtCore.Qt.AlignTop)

self.setLayout(layout)

btn1 = QtGui.QPushButton('Node Name')

btn1.clicked.connect(self.btn1Clicked)

btn2 = QtGui.QPushButton('Print Stuff')

btn2.clicked.connect(self.btn2Clicked)

dial = QtGui.QDial()

dial.valueChanged.connect(self.dialValueChanged)

layout.addWidget(btn1)

layout.addWidget(btn2)

layout.addWidget(dial)

def btn1Clicked(self):

print self.node.name()

def btn2Clicked(self):

print 'Hi, I\'m a button.'

def dialValueChanged(self):

print 'Value was just changed!'

def makeUI(self):

return self

def updateValue(self):

pass



On 7/02/16 5:41 am, Hugo Léveillé wrote:
Hey guys

I have been playing with the python custom knob based on Brent Tyler's written 
tutorial ( http://bit.ly/1OMhdTQ ). It works great to add pyside widgets inside 
gizmo. The avantage is that you only need to modify the code outside the gizmo 
the update all instances of the gizmo.

But I would like to know if it is possible to bake the code inside the python 
knob so that the gizmo/grizmo can be shared without having to have the init.py 
file with the python code

Also, since pysides knobs values are not saved when copying/saving the script, 
the only way right now to save them is in an hidden knob on reference to them 
in the __init__ function to set their values. Any better idea?

_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

--
ohufxLogo 50x50 <http://www.ohufx.com> *vfx compositing <http://ohufx.com/index.php/vfx-compositing> | *workflow customisation and consulting <http://ohufx.com/index.php/vfx-customising>* *

_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to