Pymel / Python Coding

qt designer part 2 – signals and slots

qt designer
set up gui to be imported into maya
qtdesignersphere

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

qtdesigner3

qtdesigner4

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.

qtdesigner1qtdesigner2

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

signalslot

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 ####################################

###############################################

Maya

run to create GUI which will be docked.

Comments are closed.