demoPySideQWidget.py

demoPySideQWidget.py
1 
2 '''
3  Demonstrates how to create a QWidget with PySide and attach it to the 3dsmax main window.
4 '''
5 
6 from PySide import QtGui
7 import MaxPlus
8 
9 
10 class _GCProtector(object):
11  widgets = []
12 
13 
14 def make_cylinder():
15  obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Cylinder)
16  obj.ParameterBlock.Radius.Value = 10.0
17  obj.ParameterBlock.Height.Value = 30.0
18  node = MaxPlus.Factory.CreateNode(obj)
21  return
22 
23 app = QtGui.QApplication.instance()
24 if not app:
25  app = QtGui.QApplication([])
26 
27 
28 def main():
30 
31  w = QtGui.QWidget(MaxPlus.GetQMaxWindow())
32  _GCProtector.widgets.append(w)
33  w.resize(250, 100)
34  w.setWindowTitle('PySide Qt Window')
35 
36  main_layout = QtGui.QVBoxLayout()
37  label = QtGui.QLabel("Click button to create a cylinder in the scene")
38  main_layout.addWidget(label)
39 
40  cylinder_btn = QtGui.QPushButton("Cylinder")
41  cylinder_btn.clicked.connect(make_cylinder)
42  main_layout.addWidget(cylinder_btn)
43 
44  textEdit = QtGui.QLineEdit()
45  textEdit.setText("Edit box")
46  main_layout.addWidget(textEdit)
47 
48  w.setLayout(main_layout)
49  w.show()
50 
51 
52 if __name__ == '__main__':
53  main()