There are a few things wrong with your code snippet. Below is a working version.
The main two things that seemed off are:

1. your custom panel class correctly inherits from
   nukescripts.PythonPanel but then creates a new panel inside it's
   constructor again which is odd.
2. you never called the super class's constructor which is responsible
   for all sorts of things, including hooking up callbacks internally.
   If you don't do that, you effectively overwrite the way the python
   panel is meant to be initiated and you are definitely in for
   unexpected results

Cheers,
frank

class ShapePanel(nukescripts.PythonPanel):

def __init__(self, title="ELEMENT"):

super(ShapePanel, self).__init__(title) # call nukescripts.PythonPanel.__init__() to make sure your derived class is created properly

IDs = ['12345','56789','09876']

self.d = nuke.Enumeration_Knob('Element', 'Element : ', IDs)

self.addKnob(self.d)

self.myID = self.d.value()

def knobChanged(self, knob):

if knob is self.d:

print knob.name()

p = ShapePanel()

p.showModalDialog()



On 13/08/16 2:34 AM, Bruno-Pierre Jobin wrote:
Can anyone tell me why the knobChanged function won't print the knob name when it's changed?

I came across this thread that basically asks the same question but I can't wrap my head around it.
https://www.mail-archive.com/nuke-python@support.thefoundry.co.uk/msg03270.html


class ShapePanel(nukescripts.PythonPanel):

def __init__(self):

IDs = ['12345','56789','09876']

self.p = nukescripts.PythonPanel("ELEMENT")

self.d = nuke.Enumeration_Knob('Element', 'Element : ', IDs)

self.p.addKnob(self.d)

self.ret = self.p.showModalDialog()

self.myID = self.d.value()

def knobChanged(self, knob):

if knob is self.d:

print knob['name']

ShapePanel()

Thank you

--
Bruno-Pierre Jobin


_______________________________________________
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

_______________________________________________
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