Qt Designer with Houdini

Qt Designer を使って作成したUIを、Shelfなどから呼び出す。

import sys
from hutil.Qt import QtCore, QtUiTools, QtWidgets

class MyDialog(QtWidgets.QDialog):

    def __init__(self, *args, **kwargs):
    
        #set parent
        super(MyDialog,self).__init__(*args, **kwargs)
        
        #import ui file 
        ui_file = r'D:\Houdini\sw\saveUI\saveUI002.ui'
        self.ui = QtUiTools.QUiLoader().load(ui_file, parentWidget=self)        
        self.setParent(hou.ui.mainQtWindow(), QtCore.Qt.Window)

        #connect dialog button
        dialog_btn = self.findChild(QtWidgets.QDialogButtonBox, "buttonBox") 
        dialog_btn.accepted.connect(self.ok)
        dialog_btn.rejected.connect(self.close)
        
        #connect push button
        print_btn = self.findChild(QtWidgets.QPushButton, "pushButton")  
        print_btn.clicked.connect(self.hello)        
    
    #accpet    
    def ok(self):
        self.accepted()
        hou.ui.displayMessage("ok")        
    
    #cancel    
    def close(self):
        self.reject()        
        hou.ui.displayMessage("cancel")
        pass        
    
    #function for pushbutton    
    def hello(self):
        print("hello")
        
mygui = MyDialog()
#launch the UI as mordal mode
mygui.exec_()

このブログの人気の投稿

Houdini Path 表記法

HDAの作成、更新とバージョン管理について

action buttonを使ってジオメトリをattributeベースで選択するコード