I've built a small program using python in maya, and im interested in printing the values that the user inputs upon the click of 'Apply'. Any ideas on how I can achieve this? I want to then use the values in another piece of code to create buildings inside maya.
def runGrid():
if mc.window('windowTest9', ex=True):
mc.deleteUI('windowTest9', window=True)
mc.window('windowTest9', title='BuilGen', sizeable=False, resizeToFitChildren=True)
mc.rowColumnLayout( numberOfColumns = 2, columnWidth = [ (1, 150), (2, 100), (3, 75)])
#mc.text( label = 'Top Bar')
mc.separator( h = 10, style = 'none')
mc.separator( h = 10, style = 'none')
mc.text(label='Create a New Building', align = 'left')
mc.image(image='F:\Photos\office-building-icon-687152.png')
# insert a blank line space
mc.separator( h = 10, style = 'singleDash')
mc.separator( h = 10, style = 'singleDash')
mc.text( label = 'number of sections wide:', align = 'left')
buildingWidth = mc.intField( value = 4)
mc.text( label = 'number of sections deep:', align = 'left')
buildingDepth = mc.intField( value = 3)
mc.text( label = 'number of floors:', align = 'left')
numberOfFloors = mc.intField( value = 2)
mc.text( label = 'roof:', align = 'left')
numberOfFloors = mc.checkBox (label='Y/N')
mc.separator( h = 10, style = 'none')
# insert another blank line
mc.separator( h = 10, style = 'none')
mc.separator( h = 10, style = 'none')
# create the buttons
mc.separator( h = 10, style = 'none')
mc.button( label = 'Apply', command = '' )
mc.button( label = 'Cancel', command = 'mc.deleteUI("windowTest9", window=True)')
mc.showWindow()
runGrid()
Edit: Like DrWeeny said, it would be best to refer to the other similar topics.
I did a little reminder on my blog some time ago, to be able to test all the different native Maya UI way of using commands with a fast way of testing them:
Each case is also given with examples with passing variables as arguments to those functions. Because sometimes you have to be able to. Overall I totally recommend the use functools.partial, it gives only advantages over the others (if you forget about PySide).
Maya UI types
When using a class
Because it was not made with the use of class in mind, some ways does not work at all when you are in a class.
You can go on this other post to see the answers : Printing the label of a button when clicked or the usage of dictionnary here : Maya Python - Using data from UI