在 2017年4月17日星期一 UTC+8上午4:11:13,gnn写道:
> 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?"...
> thanks for any help!!
>
> 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
my english is very poor
i think you want this:
import maya.cmds as cmds
import random
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,c='check_value()')
cmds.showWindow()
def check_value():
i=random.uniform(0,100)
cmds.intField( "Episode", e = True, value = i)#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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/6bf00b33-e868-4b3f-a515-3e405a799e81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.