PDA

View Full Version : textScrollList selection into a textField (python)


mccollom73
10-17-2011, 06:09 AM
Hey everyone!

I am trying to put the selected attribute from the textScrollField into a textField and I'm having some trouble. My controller is named ikfk_ctrl, my ikfk attrribute is "ikfk, and I want the name "ikfk_ctrl.ikfk" in the textField to be my end result. The attributes name will be put into the list, but I'm not sure how get the final result ikfk_ctrl.ikfk

Here is what I have so far.



import maya.cmds as c

def ikfkSnapWindow():

# WINDOW
win=c.window(title="IKFK Snap GUI", widthHeight=(300,500))

#LEFT TAB
left=c.formLayout()

lf_ikfkText=c.text('lf_ikfkLabel', label="IKFK Attr")
lf_ikfkField=c.textField('lf_ikfk',w=140, editable=True)
lf_ikfkBtn = c.button(label="Load", c="loadWin('lf_ikfk')")

c.showWindow(win)

def loadWin(ikfk):

win=c.window(title="IKFK Attr")
panel=c.paneLayout()

attr=c.listAttr(r=True, k=True)
sel=c.ls(sl=True)

textScroll=c.textScrollList( numberOfRows=8, allowMultiSelection=False, append=attr, showIndexedItem=4 )
ikfkField = c.textField(ikfk, edit=True, text=sel[0])
c.showWindow(win)

ikfkSnapWindow()



Thanks!
Josh

gtbull80
11-15-2011, 02:05 PM
Not sure if you were able to figure this out. But I have some tips that may get you to where you want to go.

Where you say:
ikfkField = c.textField(ikfk, edit=True, text=sel[0])

This is a problem as the textfield doesn't exist yet you're trying to edit it. Drop the edit mode, or create it first then edit it. Maybe that will help you on your way:)

CGTalk Moderation
11-15-2011, 02:05 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.