embed .ui file into HDA ?

   434   1   2
User Avatar
Member
43 posts
Joined: Jan. 2012
Offline
Hi,

Im having trouble reading embeded widget ui file.

class MyWidget(QtWidgets.QWidget):
    def __init__(self, *args, **kwargs):
        super(MyWidget, self).__init__(*args, **kwargs)
        ui_file = hou.readFile("opdef:.?widget.ui")
        ...
tried also full path
ui_file = hou.readFile("opdef:/Sop/myHDA?widget.ui")

or this
ui_file = "opdef:/Sop/myHDA?widget.ui"

Is it because readFile returns content of the file, rather then file itself ?
What it a proper way of reading embeded widget ui files from the same HDA ?
Edited by tas3d - June 5, 2018 06:39:53
Michal Tas Maciejewski @ Weta Digital
User Avatar
Member
43 posts
Joined: Jan. 2012
Offline
I got it working by saving extra files to temp file, then reading them in

        type = hou.nodeType(hou.sopNodeTypeCategory(), "xxx")
        definition = type.definition()
        sections = definition.sections()
        
        extraFiles = ('ui.png', 'ui_mask.jpg', 'widget.ui', 'about.jpg')
        tempDir = tempfile.gettempdir()
        
        for f in extraFiles:
            section = sections[f]
            filepath = os.path.join(tempDir, f)
            file = open(filepath, "wb")
            file.write(section.contents())
            file.close()
Edited by tas3d - June 6, 2018 06:38:44
Michal Tas Maciejewski @ Weta Digital
  • Quick Links