Update UI based on selected object?

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2007   #1
Update UI based on selected object?

Hi All,

I tried looking through the forum for this, but since search is busted again (whee!), I thought I'd ask the question.

I have a mel script which can create 3 particle systems. The systems can be created in the dialog by hitting buttons at the top, which in turn creates the system, or if it already exists, calls a getAttr proceedure.

examples of the type of behavior are:

1.) User clicks on the "Particle 2" button, which creates the Particle 2 set, then clicks the "Particle 1" button. The UI updates with the Particle 1 System's attributes.

2.) The user accidently closes the dialog and calls it again, and it updates with the system attributes.

I'm just unsure about how I can get the values found by the GetAttr statements back into the various fields and sliders within my UI (without calling an edit to each and every control). Is there a way to globally update the UI?

Thanks for helping out a UI newb.
 
Old 07 July 2007   #2
Sorry, but I think you'll have to call out an edit for every control. An easier way to do this though would be to write that function out as a procedure which gets executed by your button, so you won't have to input all of the -edit commands in the -command flag of your button and end up in a stringy mess.
__________________
...everything will be fine, as long as nothing goes wrong...
 
Old 07 July 2007   #3
you could setup a scriptJob ... just gotta remember to kill it when you don't need it anymore...

Seth
 
Old 07 July 2007   #4
scriptjob is right
extra kill is wrong

you can attach your scriptjob to a UI via the -parent flag.
The job is automatically killed if you close your UI.

And I'd suggest to write a proc that creates your UI upon the values from a selection! I mean create your window and then run that proc. And make the scriptjob run that proc on selectionChange.

So the UI is initially right with the appropriate values. When you change selection the UI in the window will be deleted and rebuild with the right values again.
__________________
goodsoul.de
 
Old 07 July 2007   #5
Thanks everyone!

What I ended up doing was creating a proc which gets the attributes from the given system (just like above), and then calls a delete columnlayout, and rebuilds it (parented to the original window). This seems to work just fine.

This gets the correct attribute for all the correct controls, with the excpetion of some checkboxes (which are adding/deleting fields to the system). I guess I will have to do a check for each field type (vortex, newton, drag, etc) and see if it is dynamically attached to the system, and edit the checkbox on, if needed. That is - unless anyone has a cool trick....




Originally Posted by ewerybody: scriptjob is right
extra kill is wrong

you can attach your scriptjob to a UI via the -parent flag.
The job is automatically killed if you close your UI.

And I'd suggest to write a proc that creates your UI upon the values from a selection! I mean create your window and then run that proc. And make the scriptjob run that proc on selectionChange.

So the UI is initially right with the appropriate values. When you change selection the UI in the window will be deleted and rebuild with the right values again.
 
Old 07 July 2007   #6
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.
 
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
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 05:12 PM.


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