PDA

View Full Version : Coding UI - how to remove 'extra' Tab?


Horganovski
01-09-2011, 06:42 PM
Hey Folks,

Continuing my MEL adventures in Maya I'm learning how to create UIs at the moment and I've run into a small issue I can't figure out. I've looked at some free character rigs online and their GUIs have the same issue so it seems to be a common one, but must be fixable I reckon.

Basically - if I enter the following code to create a tabbed window, even though I just want to create 2 tabs in this example, I always get an extra one right in front. So each time an animator would open this they have to switch to the correct '1st' tab. Not life-threatening, but a little annoying and I'm sure there must be a way to prevent it.

Any ideas appreciated.

Cheers,
Brian


window -t "Tab Window" -w 240 -h 430 ;
string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5 -scr 1 -hst 16 -vst 16 -cr 1 `;
string $tab1 = `columnLayout -adj 1`;
setParent..; setParent..;
string $tab2 = `columnLayout -adj 1`;
setParent..; setParent..;
tabLayout -edit
-tabLabel $tab1 "Animation"
-tabLabel $tab2 "Rendering"
$tabs;
showWindow;

NaughtyNathan
01-09-2011, 07:25 PM
you do have one too many setParent ..; commands (after the first columnLayout), but either way this code works fine on my Maya (2010 32bit, Win XP), producing only the two desired tabs, so I'm not sure where your screenshot problem lies... Maybe they broke something else in the elf support for 2011?

:nathaN

Horganovski
01-09-2011, 07:32 PM
Thanks for your reply, I'm trying this in 2011 (1st version I've owned so don't have older to check on here). Even with removing those extra setParent..; it still behaves the same way.

I had a look in the Command Reference and found this, which does work the way I want, (ie no extra tab) but so far I can't reverse engineer it enough to figure out what's making the difference. Probably I need to go back to my 'MEL 101' dvd and watch some more and it may become clearer to me : )

Cheers,
Brian

window -widthHeight 200 150;
string $form = `formLayout`;
string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5`;
formLayout -edit
-attachForm $tabs "top" 0
-attachForm $tabs "left" 0
-attachForm $tabs "bottom" 0
-attachForm $tabs "right" 0
$form;

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

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

tabLayout -edit
-tabLabel $child1 "One" -tabLabel $child2 "Two"
$tabs;

showWindow;

NaughtyNathan
01-09-2011, 09:08 PM
I've got 2011 at work so I'll try your code on that tomorrow, but I still can't see how you'd end up with an extra blank tab...? weird...

:nathaN

Horganovski
01-09-2011, 10:12 PM
Many thanks, interested to know what you find out.

Cheers,
Brian

NaughtyNathan
01-10-2011, 10:21 AM
ok, I've tried it on 2011 and it's wrong in the same way you've found. However, I've found out the problem, and it's that the tabLayout doesn't seem to be a fully "valid" top-level layout (on 2011, every older version is fine, so it must be a QT/elf conversion issue).

If you create another layout above the tabLayout (formLayout would be my recommendation) then you don't get the error.

:nathaN

Horganovski
01-10-2011, 06:30 PM
Many thanks Nathan, appreciate you looking into this. As a noob (4 years using another package - 3 weeks or so using Maya!) it's tricky to know sometimes what is user error and what's a bug/changed functionality.

Cheers,
Brian

Horganovski
01-13-2011, 11:02 PM
Just to say, I've managed to fix this issue with a couple of Gui scripts now, the main thing is to add a parent formLayout before the tabs as you said Nathan.
One other thing I had to do in a couple of cases was to use AttachForm to explicitly tie any background images to the form as otherwise they didn't show up.
I'll post the 1st part below in case it's useful for someone else.

Thanks again,
Cheers,
Brian


/// inserting form layout as parent for tab layouts

string $form = `formLayout`;
string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5`;
formLayout -edit
-attachForm $tabs "top" 0
-attachForm $tabs "left" 0
-attachForm $tabs "bottom" 0
-attachForm $tabs "right" 0
$form;

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