python - Text box entry in a GUI -



python - Text box entry in a GUI -

for class coding little chess simulator gui using python. come in move have text box can type in, , 1 time press btn move, moves piece.

currently have gui radio buttons each piece. under function btn move them have:

if btn == 4: cmds.select('a4') cmds.move()

i not know how write code simple text box in gui or propper code reference text box is.

q: how code simple working text box, , how write code functions can reference gui.

can create text box using textfield command. create typical textfield command:

my_textfield = cmds.textfield()

in maya, every ui element has unique identifier name string. when phone call textfield command in create mode, homecoming name of textfield created. here, my_textfield python variable contains name of created textfield can refer later. access text value of textfield like:

text_entered = cmds.textfield(my_textfield, query=true, text=true)

here, access text entered in textfield, calling textfield command in query mode, setting query flag true , setting text flag true. setting text=true in query mode, i.e. query=true tells command homecoming current text value of textfield. text_entered python variable contain text entered.

text fields can take sort of textual inputs might need validation. avoid validation troubles utilize intfield if know inputs need integers. (there floatfield.) using intfield similar textfield. create one:

my_intfield = cmds.intfield(minvalue=1, maxvalue=8)

minvalue , maxvalue optional parameters allow set minimum , maximum values field can accept. access value entered:

val_entered = cmds.intfield(my_intfield, query=true, value=true)

have @ documentation these 2 fields more info on else offer:

textfield intfield

python user-interface maya

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -