gordryd (4/22/2019)
@Chris - looks like you know what you are doing (as opposed to me just cobbling together pieces that others have contributed). So I created a form in QT Designer, but have questions about a few things. Here is what the form looks like in QTD:

How would I do the following?
1) Populate the Preset ComboBox from a list inside my main.py script when the form opens
2) Populate the Object ComboBox from current iClone project (with either all Cameras or all Props - Camera/Prop selection will be made before box is displayed) when the form opens
3) Pass values from SpinBoxes to main.py variables when 'OK' is clicked?
Thanks - when I get this to a stage that I am satisfied with I will make it available to all that want it.
Hi gordryd
Not sure if I would say I know what I am doing as yourself I have had a lot of experimenting and head scratching over the last couple of months but I seem to have got the basic jist at least, anyway to answer you questions see the code below.
1. Not sure how to do this as yet (see below) but You can set the options for the Combobox from within the QT Designer just right click and select "edit Items"
2. Object Combo Box
I use this function to populate a TreeWidget with all the relevant objects I wish from the scene
not sure how to set a combo box but it should be simular.
Im not at my home computer at the moment so cannot check this out but i will check this out tomorrow when I finish work and at home.
Perhaps someone with more knowlege with Combo Boxes could chime in here and put both of us right?
def get_scene_objects(ui_treeWidget):
#-----Get all avatar / prop / camera / light-----
avatar_objects = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar ) # Get all avatars in scene
prop_objects = RLPy.RScene.FindObjects( RLPy.EObjectType_Prop ) # Get All Props in Scene
light_objects = RLPy.RScene.FindObjects( RLPy.EObjectType_Light ) # Get All Lights in Scene
camera_objects = RLPy.RScene.FindObjects( RLPy.EObjectType_Camera ) # Get A Cameras in scene
ui_treeWidget.setColumnCount(1)
ui_treeWidget.setHeaderLabels(['Scene Objects'])
#Avatar level item and its kids
item0 = QTreeWidgetItem(ui_treeWidget, ['Avatar'])
#-----Create item for all scene objects-----
for item in avatar_objects:
_name = item.GetName()
QTreeWidgetItem(item0, [_name])
#Prop level item and its kids
item0 = QTreeWidgetItem(ui_treeWidget, ['Prop'])
#-----Create item for all scene objects-----
for item in prop_objects:
_name = item.GetName()
QTreeWidgetItem(item0, [_name])
#Light level item and its kids
item0 = QTreeWidgetItem(ui_treeWidget, ['Light'])
#-----Create item for all scene objects-----
for item in light_objects:
_name = item.GetName()
QTreeWidgetItem(item0, [_name])
#Camera level item and its kids
item0 = QTreeWidgetItem(ui_treeWidget, ['camera'])
#-----Create item for all scene objects-----
for item in camera_objects:
_name = item.GetName()
QTreeWidgetItem(item0, [_name])
ui_tree_view = qtui_widget.findChild(PySide2.QtWidgets.QTreeWidget, "treeWidget") # Find the tree widget
ui_tree_view.itemClicked.connect(run_tree_view) # Go and do something
def run_tree_view(it, col):
print(it.text(col)) # Print the tree widget value selected
3. Spin Boxes
some_spin_box_value = 0 # This is global for the spinbox value place under your imports at top of script
ui_spin_box = qtui_widget.findChild(PySide2.QtWidgets.QSpinBox, "spinBox") # Find the control Spin Box with name "spinBox" or your own name
ui_spin_box.valueChanged.connect(run_spin_box) # Run when spinbox updated
def run_spin_box(value):
Global some_spin_box_value
some_spin_box_value = value # Save the spinbox value to use later in the script
Hope this helps in some way.
Chris.