[HOME] [MEL] [API]

 

Mel Script - windows and GUI overview

 

 

 

Overview

mel is primarily used within Maya to control every aspect of the User Interface. There are a great number of user interface elements available to you, however i shall only deal with 3 general groups; windows, layouts and controls.

The following example demonstrates the purpose of each GUI element type.

 

 

 

 

 

Example 1 : A simple GUI

The mel command window allow us to create (suprisingly) a window. Within the window we will want to place controls, however first we must tell Maya how we want the controls to be laid out. In this case I am using columnLayout to place all controls in a column. There are a number of other Layouts available which can be used to arrange your GUI's far better than this simple example ;)

 

   

  {
	// create a window
	window;
		// define the layout of controls added 
		// to the window.
		columnLayout;
			// create a couple of buttons
			button -label "button1";
			button -label "button2";
	// show the window we last created
	showWindow;;
  }
  
 

 

 

 

 

 

Example 2 : Changing GUI Colours

we can make use of the -bgc (background colour) flag to change the colours of the user interface elements (only works under Win32 i believe). This can be really useful to colour co-ordinate your GUI elements for different parts of the pipeline. (green for exporter, blue for sound plugins, yellow for modelling etc)

 

   

  {
	// create a window
	window -title "myWindow";
		// define the layout of controls added 
		// to the window.
		columnLayout -bgc 1 0 0;
			// create a couple of buttons
			button -bgc 0 1 0 -label "button1";
			button -bgc 0 0 1 -label "button2";
	// show the window we last created
	showWindow;
  }
  
 

 

 

 

 

 

Example 3 : Commands and deleting the GUI

To delete any user interface element is simply a case of calling

deleteUI "uiElementName" ;

If we delete a window, all of it's child controls will be deleted also.

In addition, we can also assign commands to most control types. In this example we will use the -command flag to specify some mel code to be executed whenever the button is clicked. The command that we will execute will simply delete the window that was created.

 

   

  {
    // create a window and store the name
    $win = `window`;

    	// define the layout of controls added 
    	// to the window.
    	columnLayout;

   	// create a command to delete the window
	$command = ("deleteUI " + $win);

   	// create a couple of buttons
	button -label "quit" -command $command;

    // show the window we last created
    showWindow;
  }
  
 

 

 

 

 

 

Related Documents

Layouts

Controls

Menus

Attribute Controls

Common Dialogs

 

 

[HOME] [MEL] [API]