CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 10-06-2012, 02:05 PM   #1
DEVILSAN
Earth Born>> goo.gl/mJh20
 
DEVILSAN's Avatar
portfolio
Sanjeev Kumar
MPC
India
 
Join Date: Jan 2005
Posts: 290
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

Code:
def selected(): print "Selected : ", str(cmds.textScrollList("txtscrollList", q=True, si=True)) cmds.window( mnb=False,mxb=False) cmds.columnLayout() 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 ) cmds.showWindow()

in the beginning all selected items gets populated but how can I have the textScrollList updated if the selection in viewport changes...?
 
Old 10-06-2012, 02:42 PM   #2
NaughtyNathan
HighEnd3D deserter
 
NaughtyNathan's Avatar
Naughty Nathan
Technical Artist
Sony SCEE Liverpool
Manchester, United Kingdom
 
Join Date: May 2008
Posts: 2,608
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.
 
Old 10-06-2012, 03:20 PM   #3
DEVILSAN
Earth Born>> goo.gl/mJh20
 
DEVILSAN's Avatar
portfolio
Sanjeev Kumar
MPC
India
 
Join Date: Jan 2005
Posts: 290
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..

Code:
slItem=cmds.ls(sl=True) 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.columnLayout() 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 ) cmds.scriptJob(parent="textscrollList",e=["SelectionChanged","update()"]) cmds.showWindow()

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-06-2012 at 03:31 PM. Reason: added scriptJob
 
Old 10-08-2012, 12:39 PM   #4
DEVILSAN
Earth Born>> goo.gl/mJh20
 
DEVILSAN's Avatar
portfolio
Sanjeev Kumar
MPC
India
 
Join Date: Jan 2005
Posts: 290
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

cmds.scriptJob(parent="wireframeColor",e=["SelectionChanged","self.update()"])

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 ...
 
Old 10-08-2012, 03:14 PM   #5
rgkovach123
Know-it-All
robert
austin, USA
 
Join Date: Nov 2006
Posts: 364
don't put self.updateUI in quotes, and drop the parantheses


Code:
cmds.scriptJob(parent="wireframeColor",e=["SelectionChanged", self.updateUI])
 
Old 10-08-2012, 03:40 PM   #6
DEVILSAN
Earth Born>> goo.gl/mJh20
 
DEVILSAN's Avatar
portfolio
Sanjeev Kumar
MPC
India
 
Join Date: Jan 2005
Posts: 290
Wink

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...
 
Old 10-08-2012, 04:29 PM   #7
rgkovach123
Know-it-All
robert
austin, USA
 
Join Date: Nov 2006
Posts: 364
it should be killed when the UI is closed, make sure you provide the full path of the window to the parent flag.


Code:
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.
 
Old 10-08-2012, 04:29 PM   #8
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 10:23 AM.


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