How to take out a text

39 views
Skip to first unread message

kurashima

unread,
Jun 11, 2015, 3:05:05 AM6/11/15
to python_in...@googlegroups.com
In unskillful English, I'm sorry.

It's a question about pymel.
Each text of textFieldButton made by 'for'.
houhou taken out separately, please, how is it done?

import pymel.core as pm
def get_text():
    print pm.textFieldButtonGrp("tx"+str(i),edit=True).getText()
    #これだとどのボタン押しても最後のテキストがプリントされてしまう。

with pm.window(title = "gomigomi"):
    for i in range(10):
        with pm.columnLayout():
            pm.textFieldButtonGrp("tx"+str(i), text="test"+str(i), buttonLabel='<',
                                  buttonCommand = pm.Callback(get_text))

get_text()

Matt Le-Fevre

unread,
Jun 11, 2015, 5:11:44 AM6/11/15
to python_in...@googlegroups.com
Not too familiar with pymel, but I would guess you need to pass in a reference to your textFieldButtonGrp to the buttonCommand callback. In this case, you're using 'tx' + i.

import pymel.core as pm
def get_text(i):

   
print pm.textFieldButtonGrp("tx"+str(i),edit=True).getText()
   
#これだとどのボタン押しても最後のテキストがプリントされてしまう。


with pm.window(title = "gomigomi"):
   
for i in range(10):
       
with pm.columnLayout():
            pm
.textFieldButtonGrp("tx"+str(i), text="test"+str(i), buttonLabel='<',

                                  buttonCommand
= pm.Callback(get_text, str(i)))

Reply all
Reply to author
Forward
0 new messages