qt designer
set up gui to be imported into maya
new > file > form > Main Window
Layouts > Vertical Layout
into the vertical layout
drag two instances of ‘Push Button’ from Buttons in Widget Box. Rename to something that makes sense – “CreateSphere”, “ResizeSphere”
add dynamic property to “CreateSphere” and to “ResizeSphere”
first the “+command” string for python
then add in the script name. In this instance I’m referencing a script called “qtdesigner_module” where the functions for createSphere() and resizeSphere() are.
drag over an instance of a “Horizontal Slider” from Input Widgets in Widget Box. Under property editors rename QObject/objectName to “sphereSizeSlider”
drag over an instance of a “Label” from Display Widgets in the Widget Box”. This will show the value from the horizontal slider. Change text “TextLabel” to “0”.
connect up label to horizontal slider using slot editor
preview with CtrlR
Pymel Script
create a script with two functions to createSphere and resizeSphere. In this instance the script is called “qt_designer_module”. Note the two functions for create and resize that are referenced by the buttons in the GUI. The variable newValue queries the value from the “sphereSizeSlider” in the GUI. xform then scales the object (if it has been selected).
####################################
qt_designer_module.py ####################################
import pymel.core as pm def createSphere(): pm.sphere(r= 1) def resizeSphere(): selection = pm.ls(sl = True) for object in selection: newValue = pm.intSlider('sphereSizeSlider', query=True, value=True) pm.xform(scale=(newValue,newValue,newValue) )
###############################################
Maya
run to create GUI which will be docked.
import pymel.core as pm import qtdesigner_module reload(qtdesigner_module) dialog1 = pm.loadUI(f="C:/sphere_code.ui") allowedAreas = ['right', 'left'] pm.showWindow() pm.dockControl(area='left',content=dialog1,allowedArea=allowedAreas,l='Sphere_Creator')