PDA

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


giordi
02-20-2011, 03: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

dbsmith
02-20-2011, 07:33 PM
[u'example']
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:
e.g.
myList = [u'example']
myString = myList[0]

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

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

dbsmith
02-20-2011, 11:39 PM
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!

EightBit
02-21-2011, 11:29 AM
@Nathan:
nameField is cool! I never noticed that one b4.
Thanks.

CGTalk Moderation
02-21-2011, 11:29 AM
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.