LC #42 Pipers Alley

View Full Version : [PYTHON] : loading name into text field issue

02-20-2011, 04:54 PM
hi everyone i m working on a script and i need to load the name of the selection into a text field

no big deal it s easy only problem is that in the text field i will get [u' example'] and this is ugly!

so how can i just get "example" into the text field without square brackets and the u'?

any help really appreciated thank you

02-20-2011, 08:33 PM
This is a single unicode string inside a list. The u denotes that it is a string of type unicode, and will go away when you print the list's contents.

In your case, you can access the single element of the list by refering to the first entry:
myList = [u'example']
myString = myList[0]

02-20-2011, 08:56 PM
ahahah OMG i feel so dumb for that thank you so much :)

02-20-2011, 11:07 PM
also, consider using a nameField rather than a textField..

02-21-2011, 12:39 AM
No probs. Most of mayas commands return values in lists, even if only one item is returned. Dont assume that something is always returned tho!

02-21-2011, 12:29 PM
nameField is cool! I never noticed that one b4.

CGTalk Moderation
02-21-2011, 12:29 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.