Message 1 of 4

Not applicable
11-04-2020
08:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey all,
I'm trying to load a Qt ui file through python in Max, but it's not working for me. I'm following thi example I found in the docs...
http://help.autodesk.com/view/MAXDEV/2021/ENU/?guid=Max_Python_API_creating_python_uis_html
(scroll down to Loading Qt UI Files) (code pasted below as well)
I made sure to create a 'test.ui' file with a QPushButton named 'pushButton' so that I could test the example as simply as possible. However, when I run this code I do not see the UI I created in Qt Designer. Instead I just see an empty panel. I'd be grateful for anyone who can point out where I'm going wrong.
Many thanks.
import os
from PySide2.QtWidgets import QVBoxLayout
from PySide2.QtWidgets import QWidget
from PySide2.QtWidgets import QDialog
from PySide2.QtWidgets import QPushButton
from PySide2.QtCore import QFile
from PySide2.QtUiTools import QUiLoader
from pymxs import runtime as rt
class TestDialog(QDialog):
def __init__(self, parent=QWidget.find(rt.windows.getMAXHWND())):
QDialog.__init__(self, parent)
loader = QUiLoader()
ui_file_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'test_ui.ui')
ui_file = QFile(ui_file_path)
ui_file.open(QFile.ReadOnly)
self.ui = loader.load(ui_file, self)
ui_file.close()
layout = QVBoxLayout()
layout.addWidget(self.ui)
self.setLayout(layout)
btn = self.ui.findChild(QPushButton, 'pushButton')
btn.clicked.connect(self.makeTeapot)
def makeTeapot(self):
rt.teapot()
rt.redrawViews()
def main():
dlg = TestDialog()
dlg.show()
if __name__ == '__main__':
main()
Solved! Go to Solution.