Parenting your child windows isn’t strictly necessary, but I tend to use the main window as a default as a sort of "standard practice." I misread your alternate workflow and thought you were still loading widgets from UI files onto a parent class (in which case parenting the instance to the parent is a good idea for housekeeping), rather than setting up and returning top-level instances from a function.
>From the Qt docs: "If parent is 0, the new widget becomes a window. If parent is another widget, this widget becomes a child window inside parent. The new widget is deleted when its parent is deleted." Glad to hear it’s all working now though. -Nathan From: Jean-Paul LeDoux Sent: Tuesday, February 05, 2013 5:55 PM To: Nuke Python discussion Subject: Re: [Nuke-python] PySide - Proper way to define new panelclasswithQUiLoader Ok, that's great Nathan, I've got it working now - thanks for the link to pysideuic. I did refer to (er mostly copy) the code here: http://tech-artists.org/forum/showthread.php?3035-PySide-in-Maya-2013 which expands a bit on the stackoverflow snippet. Referring to the Parent question - in this Maya example, he has some code which returns the Main Maya window and he passes that to the widget. Should I be doing something similar in Nuke? Or is this handled in some way by registerWidgetAsPanel()? The examples in the nuke document don't seem to address this. Thanks again for your help. This is my working code in case it helps anyone: import PySide.QtGui as QtGui import PySide.QtCore as QtCore import PySide.QtUiTools as QtUiTools import pysideuic import xml.etree.ElementTree as xml from cStringIO import StringIO def loadUiType(uiFile): parsed = xml.parse(uiFile) widget_class = parsed.find('widget').get('class') form_class = parsed.find('class').text with open(uiFile, 'r') as f: o = StringIO() frame = {} pysideuic.compileUi(f, o, indent=0) pyc = compile(o.getvalue(), '<string>', 'exec') exec pyc in frame #Fetch the base_class and form class based on their type in the xml from designer form_class = frame['Ui_%s'%form_class] base_class = eval('QtGui.%s'%widget_class) form_class, base_class = loadUiType("/uberpanel.ui") #Path to ui file class myShinyPanel(form_class, base_class): def __init__(self, parent=None): super(myShinyPanel, self).__init__(parent) self.setupUi(self) Cheers, JP -------------------------------------------------------------------------------- _______________________________________________ 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