MEL - Maya UI Building


don’t forget the search feature Jake. searching the programming forum for “fileDialog” gives you two or three examples of exactly this issue.



It’s also going to depend on the version of Maya you’re using. Maya 2011 deprecated fileDialog so if you’re using that you’ll need to use fileDialog2 instead. If you want to see an example of both grab this script - it has examplea for both in it. I’m on my phone so apologies for not just providing the actual code.


Thanks Nathan and Pneu. Funnily enough I already had a proc written like in the link you gave.

global proc js_mapBrowserUpdate (string $map)     {
      string $fileLocation[] = `fileDialog2 -dialogStyle 2 -fileMode 1`;
     textFieldButtonGrp -e -text $fileLocation $map;

My problem was not calling the proc with an arguement properly in the -command flag of the button.

Cheers Jake


Well glad any assistance i provided (if any) was helpful. :slight_smile:



here is my first attempt towards MEL scripting

i have done a quick Blueprint Manager to ease in the task of setting up planes shaders etc for Vehicle / character Modelling.

i am still learning so there might be a few issues here and there but will solve those, once i get good idea and reference on MEL.


Hi guys,

I’m trying to make my own UI for Opening and Saving Scenes and having a plan to use it instead of original one during my current personal project.

I’m going to utilize textScrollList function with one window and some layouts in order to explorer the project folders for maya scenes.

But I faced two big problems soon.

Firstly, I can’t block backgrounds and keep my own explorer window on top, like the original file browser window.

Secondly, I don’t know if there’s a way or trick to accept ESC key input to cancel the window just like the original one.

Please help me~

Python code trick would also be welcome!


Anyone know why ‘layout -q -p someLayout’ doesn’t work at all in Maya 2008???

It works fine in Maya 2009 & 2011, but in 2008 it doensn’t return anything at all.

(There’s no error messages, though)

Second question is,

Is there a way to get the type of a certain UI??

I sometimes want to know if it’s a control, or a layout,

in some cases, if it’s just a tabLayout or a shelfTabLayout with no trashcan icon.


layoutDialog is probably what you are looking for. It provides a modal dialog that you can add your own UI layout to.


Your answer proved two facts!

I’m an idiot and you’re a genius! Ha

(so far layoutDialog was my favorite when my scripting, you know…)

It’s truly helpful, thanks a million!!


I’m not sure it proves all that :slight_smile:


This is quite a delicate question :confused: there is this command: objectTypeUI. Problem is: it works on behalf the derived control classes of Mayas UI commands. That means it returns stuff that no one can understand. For instance all grouped controls like floatFieldGrp or floatSliderGrp return “rowGroupLayout” which is not a MEL command.

Now there is a crappy way to bypass this: look if the control with the name exists! And this is a script that does this and more:

But beware!!: Maya 2009 and 2010 tend to crash Maya completely when you ask if a rowGroup exists thats not there! So better test it with an empty scene.
If there wouldn’t be this severe bug it would actually be a nice script :confused:


I can’t access to the link TT, please check it~

Your other advices are very helpful, thank you so much!!!

Ah, by the way, do you know where the icon file is, in Maya 2011??

(like mayares.dll file from older versions)


TT? all links checked. Works here :shrug:
icon file in Maya 2011? :shrug: Nope. No 2011 used yet.
I’m sorry.


Now the link works!



Hi all!

Anyone knows how to stop the shelfButton echoing all the command lines everytime I click on it?

Unlike other button controls in Maya, a shelfButton shows what it does just like the “Echo All Commands” option turned on.

It’s very annoying and not looking good.

Simple examples on this.

-c “polySphere”;

-c “polySphere”
-i “smallTrash.xpm”;

The second one spits “polySphere;” on and on and on!

What do I do with this!?!


Anyone knows how to stop the shelfButton echoing all the command lines everytime I click on it?

why on earth does it matter? But if you really don’t want the shelf button to spam your history simply write proper procedures and call those from your shelf buttons. This is what you should really be doing anyway, putting too much code on shelf buttons is not a particularly safe or efficient way to work.


I wrote a tutorial for creating simple Maya UI using Python and QT Designer.

Check it out:


Hi Nathan, thanks for your reply,
It’s very late to say this, though :slight_smile:

You’re right, that’s not that big problem but it just bothered me and I wanted to know if there are some guys who solved this wisely, that’s all :))

Anyway, for this time, I faced another problem.

I often use ‘progressWindow’ UI on heavy scripts, because there’s no way for me to find out how much jobs are left without it.

(As you know, ‘print’ command doesn’t print messages out right away during the job.)

But the problem is, often progressWindow doesn’t update both its messages and the progress line at all on very heavy jobs.

(rendering frame by frame script, for example)

I tested several times editing the interval for progress Window’s update but failed.

(It accepts the esc key input well on the other hand)

Do you guys know why?



    A bit of a MEL noob. :hmm:
    string $formula = "set of instructions followed unintelligently;   // MEL joke. :-)
    I've been trawling the net 
    (big props to Malcolm Kesson - []( ) 
    and had a little success building a little light intensity mulitplier. 
    // select lights - discards anything not a light
    // window with slider and a "do it" button pops up
    // adjust slider to multiply light intensities
    // press button
    // loops though selected lights and multiplies current value by multiplier, 
    // sets new light intensity value.
    My next - overly ambitious :scream: - idea was to create an on-the-fly dimmer board creating a sliders for each selected light. 
    Hmm ... :hmm:
    Looping through the selection makes a new slider but only the last slider actually works and all the buttons apply the last slider's value. // I haven't gotten around to applying each slider to its own light yet so ignore that bit for now.
    // Written by Craig Miller (
    // Adapted from Malcolm Kesson tutorials ([](
    global string $dimmerwin;
    global string $sldrDmmr;
    // Echoes the value of a slider in the script window
    global proc getSliderValue()
    global string $sldrDmmr;
    float $v = `floatSliderGrp -q -v $sldrDmmr`;
    string $select[] = `ls -sl -dag -lights`;
    for ($light in $select){
        float $value = `getAttr ($light + ".intensity")`;
        print ($light + " intensity is " + $value + "

setAttr ($light + “.intensity”) ($value * $v);
float $newVal = getAttr ($light + ".intensity");
print ($light + " new intensity is " + $newVal + "

    print("The current value of the multiplier is " + $v + "


    // Adds a slider and a button to the window
    global proc addUIWidgets()
    global string $sldrDmmr;
    string $select[] = `ls -sl -dag -lights`;
    int $count = size($select);
        for ($v = 0; $v < $count; $v++){
            $sldrDmmr = `floatSliderGrp -columnWidth 1 50
                            -label "Light"
                            -ann "Multiplier"
                            -field true
                            -value 1
                            -min 0.1 -max 2`;
            button  -label "Apply Multiplier Value" -command "getSliderValue";
    // Main proc
    global proc DmmrUI()
    global string $dimmerwin; 
      deleteUI $dimmerwin;
    int $doesExist = `window -exists $dimmerwin`;
    if($doesExist == 0) {
        $dimmerwin = `window -w 400 -h 200
                            -topLeftCorner 500 1000
                            -title "The Dimmer's Arms"`;
    // Should move this section to the addUIWidgets section
    //    string $select[] = `ls -sl -dag -lights`;
    //int $count = size($select);
    //for ($v = 0; $v < $count; $v++){
    //                addUIWidgets();
    //            }
    showWindow $dimmerwin;
    // Resize the window
    window -edit -widthHeight 500 250 $dimmerwin;
    // ERR  ... END CODE BIT
    I'm sure I have a problem making unique sliders.
    I think the sliders are all an instance of some sort of $sldrDmmr
    Therefore I would need to generate a unique name slider name each loop ??
    The same would go for the button command.
    Do I need to adapt the getSliderValue proc to accept an argument, that is, which slider/light to use/affect.
    Sorry if this is a bit long or convoluted.
    Any help/pointers would be greatly appreciated.
  The Next Day ...  
  Having slept on it - I do some of my best work when I'm asleep - I realised my getSliderValue needed an argument.  :lightbulb
  global proc getSliderValue (int $i)
  // Now to add an integer to my button's -command
  global proc addUIWidgets()
  global string $sldrDmmr[];
  global int $i;
  string $select[] = `ls -sl -dag -lights`;
  int $count = size($select);
  string $lightNames[] = `listRelatives -parent $select`;    // pretty names for the labels
      for ($v = 0; $v < $count; $v++){
          $sldrDmmr[$v] = `floatSliderGrp -columnWidth 1 150       //works!! individual sliders
                          -label $lightNames[$v]                         // works!!  correct name labels
                          -field true
                          -value 1
                          -min 0.1 -max 2`;
                  button  -label "Apply Multiplier Value" -command "getSliderValue $v";  //  FAIL - buttons all have 0 as argument.
  // Now this seems to run but both buttons affect the same light.
  // I have two lights selected and run script window
  getSliderValue 0;  // returns the value of the 1st slider
  getSliderValue 1; // returns the value of the 2nd slider
  // All well and good getSliderValue $i works.
  // It seems in my button creation both are getting -command "getSliderValue 0";
  // There was no reply to my last message.
  // But I live in hope.  :wavey:


Must be still in my MANIC phase... :drool:

// Realised that the button  -command "getSliderValue" was  inside "'" and thus a string!! :lightbulb
// So I changed you button line to...

button  -label "Apply Multiplier Value" -command ("getSliderValue " + $v);  // Should have thought of this!! 

// BINGO!!  


Hope this helps some one else!!


I’m having troubles with paneLayout, and would gladly ditch it for a better sollution.
Thing is I can’t get my left pane to stay at a fixed width. The Static Width Pane flag helps, but it only ensures the pane stays the same width when resizing the window.
But if I resize the window and restart the script (I want it to remember the window size of the last session) the pane width will be wrong. You define pane width by percentage of window size, so I should be able to calculate what size it should… however I don’t get the actual window size when querying my window.

Is there another way of doing this? I would rather just have to column layouts side by side, because I alwayse want my left one to be a fixed width. There’s a screenshot and download of my script here so you can see what I mean.