PDA

View Full Version : UI: How do you edit full UI windows?


stzaske
07-03-2003, 09:29 PM
I'm trying to build a wizard like interface, and say I have a Window, Step #1, with this general code:

ColumnLayout {
image control
Text
Button
}


When I change to the 2nd step of my wizard, I'll need to edit the WHOLE window, so the whole ColumnLayout section needs to change. Lets say I want the rest of the window to stay the same. I'd like the 2nd window to look like this:

ColumnLayout {
Text
textField
Button
}



From what I've gathered, I can use the EDIT command (-e) to programmatically change one of the attributes of my control, but in my case, I want the whole layout to change, so -e doesn't seem to be the right way to go about it. So my question is, how can I completely change the WHOLE columnLayout section using only one "-e" command? Or is it possible? How do most people do this?

-=STZ=-

mark_wilkins
07-04-2003, 12:44 AM
Why not just build a new window and close the old one? If all the controls are in the same place and have the same values, nobody will ever know the difference...

-- Mark

stzaske
07-04-2003, 07:12 AM
The content I am changing is one tab out of three on a tabbed interface. I guess I could STILL rebuild the whole thing, but it seems like just replacing the TAB would be more elegant.

-=STZ=-

dwalden74
07-04-2003, 07:35 PM
hmm, interesting. However, itīs not exactly clear what you need to do, and (more importantly) why- ? For example, maybe what you want to do is possible, but your immediate approach is not the best one. One solution that you can think about is making different layouts visible or not with the "-visible" flag. Another thing you could do would be to make the entire contents of the layout into a string, and then when it comes time to actually create the UI, you could just use the "eval" command on this string.

I think there are many possible solutions to your problem, but to be able to pinpoint the corrent one Iīd have to have a little more specific info. Why donīt you post your script in its current state then we can see it a little better. Iīd actually be interested in seeing it.

:beer:
David

stzaske
07-05-2003, 08:27 AM
Here is my code sample:


proc deleteOldUI(){
// windowPref -remove ZAR_WizUI; // Remove the prefs for the Window size
if (`window -exists ZAR_WizUI`){
print ("deleting window\n"); //debug code, to see where I am
deleteUI ZAR_WizUI; //delete step windows if it already exists
}
}

global proc Z_AutoRig(){

//Variables
string $gRigName; // Initialize variable that tracks Rig Name

deleteOldUI; // Delete any old windows if they exist
window -t "Zaske's Auto Rigger" ZAR_WizUI;
string $form = `formLayout`;
string $tabs = `tabLayout -w 500 -innerMarginWidth 15 -innerMarginHeight 15 tabTemp`;

string $child1 = `rowColumnLayout //This is the 1st tab, the tab that needs to change each step
-cs 2 35
-cw 1 300
-cw 2 200
-numberOfColumns 2 instruz1`;
text
-label "image goes here"
-align "left"
wizimage;
//this is the location of the text in the wizard
columnLayout instset;
text
-label "Step #1, text"
-align "left"
gInstructionText; //Name of the Text control
textField
-w 140
-tx "Rig_Name"
tfPlace;
setParent ..; //return to rowColumnLayout
text
-label " "
-align "left"; //Name of the Text control
rowColumnLayout;
button
-l "Next >>"
-c SecStep; //once this button is pressed, this whole tab needs to be updated.
setParent ..; //return to Column
setParent ..; //return to Tablayout

string $child2 = `rowColumnLayout -numberOfColumns 2`;
text
-label "Text1: "
-align "right"
tSetting_RigName;
textField
-w 200
-tx "name"
tfSetting_RigName;
text
-label "text2: "
-align "right"
tSetting_TOH_TY;
textField
-w 200
-tx "0"
tfSetting_TOH_TY;
text
-label "text3: "
-align "right"
tSetting_Root;
textField
-w 200
-tx "1"
tfSetting_Root_TY;

setParent ..;
string $child3 = `rowColumnLayout -numberOfColumns 2`;
button;
setParent ..;

tabLayout -edit
-tabLabel $child1 "Wizard" -tabLabel $child2 "Settings" -tabLabel $child3 "Create"
$tabs;

showWindow ZAR_WizUI; //Show the window
}

dwalden74
07-07-2003, 08:08 AM
-c SecStep; //once this button is pressed, this whole tab needs to be updated.


still not sure what you want here. What happens to the tab when it is supposed to update itself? How do you want it to change? Do you want to proceed to the next tab?

:beer:
David

stzaske
07-07-2003, 09:06 AM
Originally posted by dwalden74
still not sure what you want here. What happens to the tab when it is supposed to update itself? How do you want it to change? Do you want to proceed to the next tab?

Let me see if I can explain better.

I want all the controls on the tab to be replaced. The tab window is a WIZARD window, and each time I move on to the next step I want the freedom to totally rebuild the tab. Imagine my "step #1" tab is made up of ONLY text. Once the user steps to "step #2", say I want to show in step 2, 13 images (on that tab). Understand? Many controls on the tab are changing all at once. It seems that I might just have to rebuild the WHOLE window every time I move to the next step, but it seems like there is a more efficent way.

-=STZ=-

dwalden74
07-07-2003, 08:23 PM
hmm. Itīs a bit clearer. It sounds like you might want to rebuild the window each time (like markīs original suggestion). You should then assign variables to the contents of each tabīs controls. Then update these variables with arguments coming from the procedure attached to the control thatīs causing the update or forcing the rebuild. This shouldnīt be such a bid deal, but you might want to make sure that the layout for each tab is built in such a way as to accomodate the different needs of your various setups.

...unless, of course someone has a better suggestion...?

:beer:
David

ajk48n
07-08-2003, 01:50 AM
What if you just edit the fields in the tab layout to display what you want to show when you click the :next step" button. Such as

$win = `window win`;
$column = `columnLayout col`;
$action = `button -label "1st" -c "step1($action)"`;
showWindow;

proc step1(string $action)
{
button -e -label "New" -c "step2()" $action;
}

stzaske
07-08-2003, 03:07 AM
Originally posted by dwalden74
hmm. Itīs a bit clearer. It sounds like you might want to rebuild the window each time (like markīs original suggestion).

If that is the case, that I'll need to rebuild the whole window just to add a new control onto a tab, then is there a way to have the same tab appear in two different windows? Is there a way to make the same tab a child of two different windows? I was planning on having 2 other tabs, each of which would be dynamically changing throughout the script. Now, if I going to be rebuilding the full window, those two tabs are going to be MIRRORED in memory once for each new window. If I am understanding you correctly, in memory I'd have something like this

WinA1
tabA1
tabA2
tabA3

WinB1
tabB1
tabB2
tabB3

WinC1
tabC1
tabC2
tabC3

WinD1
tabD1
tabD2
tabD3

So either I can somehow reuse the same tabs in two different windows or I'll have to dupilcate the tabs for each step in my wizard. For that I'd need to write another procedure that always makes tabA2 = tabB2 = tabC2 = tabD2

and makes

tabA3 = tabB3 = tabC3 = tabD3

How could we fix a shortcoming in MEL like this? Maybe something like a new command that swaps one layout for another. That way I could easily swap out ALL of the UI layout within ANY UI element. So for example I could create a window (tab, whatever) with this layout:

rowColumnLayout -name wizStep1 {
button;button;button;
}

then do something like:

layout $wizStep2 = `text; text; textField`;

swapLayout wizStep1 $wizStep2;

Maybe this is crazy talk. -=STZ=-

rollmops
07-10-2003, 09:47 AM
:drool:
Be patient Melanie (http://www.exood4.com/melanie.php?lang=en) is comming soon and it's free!

bentllama
07-10-2003, 10:43 AM
Originally posted by rollmops
:drool:
Be patient Melanie (http://www.exood4.com/melanie.php?lang=en) is comming soon and it's free!

i love where this app is going. when is the new version due for release?

mark_wilkins
07-13-2003, 10:18 PM
I looked at this in some detail in response to another question on here, and divined the appropriate solution by looking at the MEL code that creates the Attribute Editor (which is all perfectly readable in your Maya installation.)

The solution is to use deleteUI to get rid of the layout, setParent to tell Maya where to put new UI elements, and then just make a new layout where the old one was.

-- Mark

stzaske
07-14-2003, 05:57 AM
Thanks Mark, I'll look into it. I knew there'd be a way to rebuild just a section of UI.

-=STZ=-

CGTalk Moderation
01-15-2006, 01:00 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.