Discussion:
[Maya-Python] Maya-Python] get the cmds.intField when button pressed?
emmanuelle manue154
2017-04-16 20:06:02 UTC
Permalink
Hello, i need to make an ui layout in python inside maya,
it is asking some questions and when the button is pressed,
put the entries of intField or textField into variables...
very simple but i can't find the solution: "if button pressed?"...
thank you to help me!!

import maya.cmds as cmds
window = cmds.window(title = "Open Last scene", width = 150, height = 100)
cmds.rowColumnLayout( numberOfColumns=2, columnAttach=(1, 'left', 0), columnWidth=[(1, 100), (2, 250)] )
cmds.text( label='Episode: ', align='left' )
cmds.intField( "Episode", minValue = 0, maxValue = 100, value = 0)
cmds.separator( h=5, style='none' )
cmds.rowColumnLayout( numberOfColumns=1, columnAttach=(1, 'left', 0), columnWidth=[(1, 100), (2, 250)] )
cmds.button('Open', l="Open Last scene", w=180, h=30)
cmds.showWindow()

#if button pressed??
#put the intField into a variable:
EpisodeName = `cmds.intField( "Episode", query = True, value = True)`
print EpisodeName
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/HE1PR02MB0729657921E088033C4E02838D070%40HE1PR02MB0729.eurprd02.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.
Russel Rehmund
2017-04-17 14:58:20 UTC
Permalink
You could use a class to store those field values...

self.text_val = cmds.text( label='Episode: ', align='left' )

Then you need to give the command to run on button press, then you could
query those fields to put into vars.

cmds.button('Open', l="Open Last scene", c= "get_field_values()", w=180,
h=30)

def get_field_values():
text_val = self.text_val

Hope that makes sense?
Post by emmanuelle manue154
Hello, i need to make an ui layout in python inside maya,
it is asking some questions and when the button is pressed,
put the entries of intField or textField into variables...
very simple but i can't find the solution: "if button pressed?"...
thank you to help me!!
import maya.cmds as cmds
window = cmds.window(title = "Open Last scene", width = 150, height = 100)
cmds.rowColumnLayout( numberOfColumns=2, columnAttach=(1, 'left', 0),
columnWidth=[(1, 100), (2, 250)] )
cmds.text( label='Episode: ', align='left' )
cmds.intField( "Episode", minValue = 0, maxValue = 100, value = 0)
cmds.separator( h=5, style='none' )
cmds.rowColumnLayout( numberOfColumns=1, columnAttach=(1, 'left', 0),
columnWidth=[(1, 100), (2, 250)] )
cmds.button('Open', l="Open Last scene", w=180, h=30)
cmds.showWindow()
#if button pressed??
EpisodeName = `cmds.intField( "Episode", query = True, value = True)`
print EpisodeName
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit https://groups.google.com/d/
msgid/python_inside_maya/HE1PR02MB0729657921E088033C4E0
2838D070%40HE1PR02MB0729.eurprd02.prod.outlook.com
<https://groups.google.com/d/msgid/python_inside_maya/HE1PR02MB0729657921E088033C4E02838D070%40HE1PR02MB0729.eurprd02.prod.outlook.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Russel Rehmund

***@gmail.com
www.the3daddict.com
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABGnDPSej-8FwOyiYGJzoWoT5gxt4WMe9jhmZFMxUsbRsCHODQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
gnn
2017-04-17 17:42:48 UTC
Permalink
Thank Russel, it seems to work now :)
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/10705fcb-c18e-4684-afca-648ab469cb35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...