demoPySideQWidget.py

demoPySideQWidget.py
1 
2 '''
3  Demonstrates how to create a QWidget with PySide2 and attach it to the 3dsmax main window.
4 '''
5 
6 from PySide2 import QtCore
7 from PySide2 import QtWidgets
8 import MaxPlus
9 import pymxs
10 
11 def make_cylinder():
12  cyl = pymxs.runtime.Cylinder(radius=10, height=30)
13  pymxs.runtime.redrawViews()
14  return
15 
16 class PyMaxDialog(QtWidgets.QDialog):
17  def __init__(self, parent=MaxPlus.GetQMaxMainWindow()):
18  super(PyMaxDialog, self).__init__(parent)
19  self.setWindowTitle('Pyside Qt Window')
20  self.initUI()
21 
22  def initUI(self):
23  main_layout = QtWidgets.QVBoxLayout()
24  label = QtWidgets.QLabel("Click button to create a cylinder in the scene")
25  main_layout.addWidget(label)
26 
27  cylinder_btn = QtWidgets.QPushButton("Cylinder")
28  cylinder_btn.clicked.connect(make_cylinder)
29  main_layout.addWidget(cylinder_btn)
30 
31  self.setLayout(main_layout)
32  self.resize(250, 100)
33 
34 
35 def main():
37 
38  w = PyMaxDialog()
39  w.show()
40 
41 if __name__ == '__main__':
42  main()