populating more items to list

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  10 October 2012
Question populating more items to list

I am trying to fill the list of object selected , but I want to change the list items once the selection is changed in the viewport

def selected():
	print "Selected : ", str(cmds.textScrollList("txtscrollList", q=True, si=True))
cmds.window( mnb=False,mxb=False)
cmds.button(l="update selected items in list below")
txtscrollList=cmds.textScrollList("txtscrollList",sc='selected()',aas=False,ams=True, numberOfRows=8, allowMultiSelection=True,append=cmds.ls(sl=True), showIndexedItem=4 )

in the beginning all selected items gets populated but how can I have the textScrollList updated if the selection in viewport changes...?
  10 October 2012
you need a separate function that clears the textScrollList and then populates it with the selected items. Then you just need to attach this function to a scriptJob using the "SelectionChanged" event. Also make sure you parent the scriptjob to your UI so it is killed when your UI is closed.
  10 October 2012
Thumbs up yipeee...

hey hey scriptJob I would use it incase I want to automatically update list in the textScrollList

but if It has to be updated on button click I came up with this..

 def selected():
 	print "Selected : ", str(cmds.textScrollList("textscrollList", q=True, si=True))
 def update():
 	textscrollList=cmds.textScrollList("textscrollList",edit= True,  ra=True )
 	return cmds.textScrollList("textscrollList",edit= True, sc='selected()',ams=False, numberOfRows=8, allowMultiSelection=True,append=cmds.ls(sl=True), showIndexedItem=4 )
 cmds.window( mnb=False,mxb=False)
 cmds.button(l="update selected items in list below",c='update()')
 cmds.textScrollList("textscrollList",ebg=False,sc='selected()',ams=False, numberOfRows=8, allowMultiSelection=True,append=cmds.ls(sl=True), showIndexedItem=4 )

that was easy but now....
the only problem is allowMultiSelection turned false still allows multiple selection...any help on that ???

Last edited by DEVILSAN : 10 October 2012 at 03:31 PM. Reason: added scriptJob
  10 October 2012
now I am stuck into new problem, well since I had this thing working I placed this whole code into class where it was supposed to be, now that update is also inside the same class I had it written like
def update(self):

and another method which is

def createUI(self):

has this script job after controls is goes like this


even though they are in the same class i get error # NameError: name 'self' is not defined #

well i guess I followed it write in OOP concept but still got error ...
  10 October 2012
don't put self.updateUI in quotes, and drop the parantheses

cmds.scriptJob(parent="wireframeColor",e=["SelectionChanged", self.updateUI])
  10 October 2012

yes i did figured it out , well when I was building it in non-OOP approach I had the same function call in inverted commas... and it worked

now i am stuck with new problem that how do I exit scriptJob because even if i quit my window i get update of the function...
  10 October 2012
it should be killed when the UI is closed, make sure you provide the full path of the window to the parent flag.

self.scriptJob = cmds.scriptJob(parent='MayaWindow|myWindow', 
					 event=['SelectionChanged', self.updateUI])

as a side note, when I build UI's using PyQt, scriptJobs are not killed when the UI is shutdown, I need to explicitly kill the script job by re-implementing the closeEvent.
  10 October 2012
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 06:08 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.