`registerWidgetAsPanel()` returns a PythonPanel instance when create=True (its 
`.addToPane()` method also returns a reference to itself), and the panel has a 
PyCustom_Knob stored in an attribute called `customKnob`. The PyCustom_Knob 
class then has a `.getObject()` method, which returns a simple holder for the 
actual Qt object instance (stored in a `widget` attribute).

So, to get from the registered panel to the Qt object, use:

panel = panels.registerWidgetAsPanel(name, title, identifier, 
create=True).addToPane(pane)
gui = panel.customKnob.getObject().widget


-Nathan



From: Fredrik Averpil 
Sent: Sunday, October 06, 2013 4:48 AM
To: Nuke Python discussion 
Subject: [Nuke-python] How to access UI elements from panel?

Hi, 

I am having issues with accessing UI elements when having created a panel in a 
script which creates both regular windows and panels.

I need to access the UI elements, from both windows and panels, like this: 
gui.listWidget.addItem('hello')
...and that works perfectly fine if I create a regular floating window 
(dockedWindow = False), but I can't make it to work when I create panels 
(dockedWindow = True).

Any ideas?




class HelloWorld(form, base):
def __init__(self, parent=None):
super(HelloWorld, self).__init__(parent)
# ...


def run():
dockedWindow = True


if dockedWindow:
pane = nuke.getPaneFor('Properties.1')
global gui
gui = panels.registerWidgetAsPanel( moduleName + 'HelloWorld' , windowTitle, 
('uk.co.thefoundry.'+windowObject+'Window'), True).addToPane(pane)
else:
global gui
gui = HelloWorld()
gui.show()




Regards,
Fredrik


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

Reply via email to