MEL - Maya UI Building


if you want your left column a fixed width, why are you using paneLayout then? if you want two columns side by side use a formLayout or evan a simple rowLayout



I was using a paneLayout because it was the only layout type that I could successfully attach the texture editor to (a scriptedPanel with the pane layout as parent). I’m trying now with the rowLayout but it just will not show.

   Edit: Not having any luck with formLayout either. What am I doing wrong? 
   First I detach any existing texture editors, before creating the UI elements.

uvTextureViews = cmds.getPanel(scriptType=‘polyTexturePlacementPanel’)
if len(uvTextureViews):cmds.scriptedPanel(uvTextureViews[0], e=True, unParent=True)

[/b]form = cmds.formLayout(nd=2)

texturePanel = mc.scriptedPanel(uvTextureViews[0])

column = cmds.columnLayout (‘MainColumn’, columnWidth=220)
#A bunch of UI stuff loaded into this column#
[b]cmds.formLayout(form,edit=True, attachForm=[(column,‘left’,0),(texturePanel,‘left’,220)])

[/b]But all I get is:

RuntimeError: Object’s name ‘polyTexturePlacementPanel1’ is not unique.


I am a real newbie when it comes to mel and stuff. What I want is to attach a custom toolbar to uv texture editor window’s bottom. How can I do that?
For that matter, I can’t figure out how to attach anything to anything.

This is how I would do it. If anyone else has more advice or a better way to do it, I'd love to know!

But this should at least get you started in the right direction:

    // With Texture editor open, this captures the main frame layout into a variable
 $texFrame = `frameLayout -q -p textureEditorToolbarFrameLayout`;
 // That variable will contain a long name separated by pipes, "|"
 // We need to extract the right layout from that long name, so we'll 'tokenize' it,
 // which means separating it based on a certain string
 // We need to made make string array to put the separated $texFrame into
 string $buffer[];
 // In case you run this more than once, we'll clear that array
 // Tokenize it. The first intput in tokenize is the input string,
 // the second is what we'll separate it with. the pipe '|' is a special character,
 // so we need to escape it with '\'. Look up regular expressions to learn more on that.
 // The third is the array that we put the separated strings into.
 // Tokenize returns an int number of items that were separated, so we capture that with $numT
 $numT = tokenize($texFrame, "\|", $buffer);
 // So now we want to get the children from the formLayout that we separated
 // Since the string we want (which is the formLayout) is the last in the array, we get it with:
 //   [$numT - 1]. Since $numT is the number of items separated, we subtract one since it's 0 based
 $texChildren = `formLayout -query -childArray $buffer[$numT - 1]`;
 // We'll make a button and attach it to the form layout
 $testButton = `button -p $buffer[$numT - 1] testBtn`;
 // Now we need to edit the formLayout to attach the button
 // Look up formLayout to learn more on how you can attach it in different ways.
 formLayout -e
 		-attachForm $testButton "left"   0
 		-attachForm $testButton "right"  0
 		-attachControl $testButton "top"	0 $texChildren[1]
 		-attachForm $testButton "bottom" 0
 		-attachForm $texChildren[1] "left"   0
 		-attachForm $texChildren[1] "right"  0
 		-attachControl $texChildren[1] "top"	0 $texChildren[0]
 		-attachPosition $texChildren[1] "bottom" 0 90
 	$buffer[$numT - 1];

Obviously you’d eventually want to attach some layout instead of just a button, but that should hopefully give you some ideas.


Attempting to change basic maya UI again.

We are now starting to use Maya 2012 in our department as a standard.

Since I can't stand the color scheme OR much any of the other ones I know about I use a command to change the color of the main UI.
window -e -bgc .79 .79 .79 $gMainWindow;

This never sticks… it always resets on the next start. Where can I modify this color as the default? There is no setting for it in the plain color preferences, though there should be, and I can’t seem to find its entry anywhere.

Is there a MEL file I can edit to get this color to stay?

I mean, how does the

"E:\Program Files\Autodesk\Maya2012\bin\maya.exe" -style windowsxp

command specific “-style whatever” get its information from? I want to edit that.

Mainly because I want also to get rid of the HORRIBLE contrast they have in any of the UI choices. The default is too dark with no contrast and the other options have these glaring white boxes which need to be fixed. As well as the timeline slider.

default using above style.

yuck… just like every other option. A little better then the dark UI. But those damn bright white boxes… ARG! Seriously. Who ever put these UI color schemes together needs to go back to design school and learn basic color theory.

Using gmainwindow command with photoshop to get desired look. AH… easy like sunday mornin on the mind. Seriously though, money might exchange hands if you can give me the solution. Because I am lamenting using the new QT daily due to these horrible color schemes. Since I am being forced I am trying to save what is left of my eyes as a last ditch effort. The grey allows both black and white to be read easily. Its a mid tone grey so it wont leave white blocks in your eyes OR like the dark UI leave much to be desired with no contrast for reading the text easily, especially in the outliner, script editor, etc. May not be to others liking but my eyes would thank you… right click VIEW IMAGE to see full size.


if you want

window -e -bgc .79 .79 .79 $gMainWindow;

to be executed on each Maya start put it into a userSetup.mel located in the userScriptDir

internalVar -usd;


He’s also wondering about how to change the background color in the outliner if I understood him and I’m also curious about that.


Thanks for the tip. Gah, sometimes the easiest solution is overlooked.

At the moment. I have found a few more commands to force change colors.

Adrian Graham sits next to me at DD. He is one of the original UI developers/programmers from the Alias days. You may have watched a tutorial DVD of his at one time or another on particle fx and dynamics and what not.

He is looking at a way to tweak it. But, it (outliner bg color and other misc) may very well need to be tweaked in QT designer. He’s checking it out now.


How can one parent a hudButton with a global procedure?

It seems I have to make all my strings global for it to work otherwise it cannot find it.


quick question about keeping windows open when loading a new file.

I apologise in advance if this question has already been asked, Ive spent so long searching for an answer.

I’ve created a window that I want to remain open when I load in a new scene, The window that I’ve created has a button that runs a command whereby it saves the current scene as a new version, runs a fix cache script then re-opens the scene. yet on re-open all my windows disappear.

what seems to confuse me the most is I’ve been using this tool for a few days now and it wasnt deleting any windows on re-open yet now it does.

I’ve considered including in my command the addition of a scriptNode so it re-loads the window yet I’m sure there is an easier answer

any suggestions are greatly appreciated


Hmm, well I figured out that if your
window -e -bgc .x .x .x $gMainWindow; .5 .5 .5 or lower the bg color will be the dark gray. If its .51 .51 .51 or higher it will be pure white.
   I suppose the color at .5 .5 .5 is a little better but the outliner and script editor still need tweaking with being too dark or too bright. I made the hidden text back to the old blue but slightly brighter because the dark grey is just ridiculous, couldn't tell what was hidden or not in some cases. Also the gold icons are strange. I was trying to figure out how to edit the mesh icons back to the old blue colors. Plus... some of the hypershade icons are worse too. The spot info node took me a bit to spot. 
   I tried to do 2012 today at work.... but after I noticed my face getting closer and closer to the screen slowly over the course of 20 minutes I pulled back and just exported the scene to 2009 again. In Linux flavor ... as ugly as the old 2009 interface is to some people I prefer the mid range gray look and view ports. 
   Maybe in 2013 they will give us better control over it all. :arteest:
  Don't meant to be bitchy, but as soon as I went back to 2009 the speed was there, the eye strain was gone and little things like switching between the channelbox and attribute editor wasn't weird /buggy everytime. Marking menus were instant.. etc etc. I love maya the best out of all the apps. 
 Oh does everyone else have to resize the hypershade everytime they open it?

The area with the shader choices is taking up too much space. I always have to size up the work area and size down the shader list.


Just realized that Softimage is probably the other big factor here. Since I had used that for a long time I was used to its midrange gray UI. Which is really great all around. Black and white texts are easily readable. Oh yeah. Feature request… IF Maya has an unchangable UI color theme make it so its closer to Softimage’s colors. Which is without a doubt the best one so far of any app.

Right now I am using .5 .5 .5 and its not a bad compromise… might make due.



I’d like to know, if anyone has found any way to build custom UI-controls. Basically all I need is a canvas-control where I can draw with c++ API.

Also is there any way to query/get the top and left coordinates of ui-controls placed on formLayout and -attachPosition command in MEL?



So I’ve been battling with this UI last night and couldn’t get it to look as I want.
I want the radio button to keep it’s position centered in the columnlayout which is then parented to a formlayout. I obviusly got the label flag to behave correctly, but not the radiobutton itself. I just can’t seem to get it under control. The idea is to have 8 radio buttons in a row and be able to scale the window and have the radiobuttons follow.

This is what I have now

This is what I want

and this is the

global proc newWin(){

if (`window -q -ex autoRigWin`)
    	deleteUI autoRigWin;

    window -w 230 -h 60 -t "New Win" autoRigWin;

    string $Form = `formLayout`;
	string $formBtm = `formLayout`;
	setParent $Form;
	string $formTop = `formLayout`;
	string $form1 = `formLayout`;
	string $col = `columnLayout -adj 1`;
	string $btn1 = `radioButtonGrp
					-adj 1
					-cw 1 20
					-cal 1 "center"
					-numberOfRadioButtons 1
					-label "cm "`;
	//string $btn1 = `button -l "1"`;
	setParent $col;
	setParent $form1;
	setParent $formTop;
	string $form2 = `formLayout`;
	string $btn2 = `button -l "2"`;
	setParent $form2;
	setParent $formTop;
	setParent $Form;
	string $tab = `tabLayout`;
    string $masterForm = `formLayout`;
    string $topForm = `formLayout`;
	setParent $masterForm;
	setParent $tab;

    string $masterForm2 = `formLayout`;
    string $topForm2 = `formLayout`;
    setParent $masterForm2;
	setParent $tab;

    string $masterForm3 = `formLayout`;
    string $topForm3 = `formLayout`;
    setParent $masterForm3;
	setParent $tab;

    string $masterForm4 = `formLayout`;
    string $topForm4 = `formLayout`;
	setParent $masterForm4;
	setParent $tab;

    string $masterForm5 = `formLayout`;
    string $topForm5 = `formLayout`;
	setParent $masterForm5;
	setParent $tab;

    string $masterForm6 = `formLayout`;
    string $topForm6 = `formLayout`;
	setParent $masterForm6;
	setParent $tab;

    string $helpForm = `formLayout`;
    string $helpField = `scrollField -text "some help text.. or whatever"`;
    setParent $helpForm;
    setParent $tab;

tabLayout -e -tli 1 "Spine/Neck" -tli 2 "Arm" -tli 3 "Leg" -tli 4 "Tail/Tentacle" -tli 5 "Extras" -tli 6 "Save/Load Layout" -tli 7 "Help" $tab;
int $rowHeight = 25;
int $border = 5;
setParent $Form;

string $b1dBtn = `button
                    -l ("Build")
					-bgc 0 0.9 0
                    -c "build"`;

setParent $Form;

formLayout -e
	//-ac $tab "top" 10 $topCol
	-ap $tab "top" 0 20
	-af $tab "left" 0
	-af $tab "right" 0
	-ap $tab "bottom" 0 90

formLayout -e
	-ac $b1dBtn "top" 0 $tab
	-af $b1dBtn "left" 0
	-af $b1dBtn "right" 0
	-af $b1dBtn "bottom" 0

formLayout -e
	-af $formBtm "top" 0
	-af $formBtm "left" 0
	-af $formBtm "right" 0
	-ap $formBtm "bottom" 0 95

formLayout -e
	-ap $formTop "top" 0 10
	-af $formTop "left" 0
	-af $formTop "right" 0
	-ac $formTop "bottom" 0 $tab

formLayout -e
	-af $form1 "top" 0
	-af $form1 "left" 0
	-ap $form1 "right" 0 50
	-af $form1 "bottom" 0
formLayout -e
	-af $form2 "top" 0
	-ap $form2 "left" 0 50
	-af $form2 "right" 0
	-af $form2 "bottom" 0
formLayout -e
	-af $col "top" 0
	-af $col "left" 0 
	-af $col "right" 0
	-af $col "bottom" 0

formLayout -e
	-af $btn2 "top" 0
	-af $btn2 "left" 0
	-af $btn2 "right" 0
	-af $btn2 "bottom" 0
formLayout -e
    	-af $topForm "top" 0

    	-af $topForm "left" 0
    	-af $topForm "right" 0


formLayout -e
    	-af $topForm2 "top" 0

    	-af $topForm2 "left" 0
    	-af $topForm2 "right" 0


formLayout -e
    	-af $topForm3 "top" 0

    	-af $topForm3 "left" 0
    	-af $topForm3 "right" 0


formLayout -e
    	-af $topForm4 "top" 0

    	-af $topForm4 "left" 0
    	-af $topForm4 "right" 0


formLayout -e
    	-af $topForm5 "top" 0

    	-af $topForm5 "left" 0
    	-af $topForm5 "right" 0



formLayout -e
    	-af $topForm6 "top" 0

    	-af $topForm6 "left" 0
    	-af $topForm6 "right" 0

formLayout -e
	-af $helpField "top" 0
	-af $helpField "left" 0
	-af $helpField "right" 0
	-af $helpField "bottom" 0  

window -e -w 585 -h 175 -topEdge -80 -leftEdge 10 autoRigWin;
    showWindow autoRigWin;


I have a problem with the command projFileViewer.I don’t Know if it’s a maya 2012 bug but the example of maya help doesn’t work, anybody else has the same problem?

this is the example of maya help:

import maya.cmds as cmds

cmds.window( ‘ProjWindow’, rtf=0, wh=(150, 150) )
cmds.paneLayout( ‘ProjPanes’ )
cmds.projFileViewer( ‘ProjFileView’, dm=0 )
cmds.paneLayout( ‘ProjPanes’, e=True, cn=‘single’, sp=(‘ProjFileView’, 1) )
cmds.projFileViewer( ‘ProjFileView’, e=True, fr=True )

thanks in advance


I have a very old question about Maya UI
Is there anyway to insert a background picture into Maya Window?

Anything would help. Thanks


Hey Dude!
Of course, but then you must use a form layout and put it in. In prior versions of maya like up to 8 or so(please correct me if I’m wrong) html was implemented so you could create more dynamic and nicer looking UI:s, but it was scrapped before I had time to try it out(Don’t understand why either) :frowning:
However as per the implementation of QT the feature is back. This is what I’ve understood anyway, haven’t tested it yet myself. Is this info correct?

Anyway. here’s some links to mel UI:s using formlayouts to add a background image


I also think there is no direct way to insert a BG pic into an UI window
Thanks for the information


What do you mean? In a MEL UI you can attach it to a formlayout following the links I posted. It’s the most simple and direct way =)

Perhaps I threw you off rambling on about QT and html implementation hence that’s a way to create nicer looking UI:s, but using MEL with the formlayout would be what you’re looking for. Good luck!


@Geuse: Sorry man, i’m new to MEL script so maybe my post not make any sense.
However your post very useful and it gave me the result i want. Thanks again

Edit: I have one more question. I try to create FacialGUI. Like this

The Area box in the middle look like a slider but i can’t find any command to create it.


Cool dude! Keep it up.