[HOME] [MEL] [API]

Mel Script - User Interface Layouts

 

 

 

When placing User Interface controls into your window's, need need to specify a layout for those items. Maya contains a number of different layout controls for different purposes. This page will examine a few of the basic types.

 

 

 

 

Example 1 : columnLayout

The simplest of all layouts is the columnLayout. This simply places all controls in a vertical column.

 

	{
		// 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";
				button -label "button3";
		// show the window we last created
		showWindow;
	}

 

 

Example 2 : rowLayout

The rowLayout simply places all controls in a horizontal row. We need to specify the number of columns to be used in the row (ie, how many controls we wish to place underneath it). In this example the width of the 3 colums is also specified

 

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

 

 

Example 3 : frameLayout

A frameLayout creates a collapsable layout. The frame can only hold a single user interface item. Therefore if you want more than one control inside the frame, you will need to nest another layout inside the frame layout.

 


	{
		// create a window
		window;
			// create a collapsible frame layout
			frameLayout -collapsable true -label "my frame";

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

					// create a couple of buttons
					button -label "button1";
					button -label "button2";
					button -label "button3";
		// show the window we last created
		showWindow;
	}	
		

 

 

Example 4 : setParent

As soon as we create a layout, all new GUI elements will automatically be added underneath the new layout. Often though we want to change the default layout underwhich controls get parented.

The following example places 2 frame layouts underneath a columnLayout. Within each frame layout is a columnLayout which contains some controls. So, having finished adding controls to frame 1, we need to set the highest columnLayout as the current parent so that frame2 will be added underneath that rather than frame1.

to do this, we could either use setParent $ui_name or we can use setParent .. which takes us up a single level in the GUI.

 


	{		
		// create a window
		window;

			// two frame layouts will be laid out in a column
			columnLayout;
	
				// create a collapsible frame layout
				frameLayout -collapsable true -label "frame1";
	
					// define the layout of controls added 
					// to the window.
					columnLayout;
	
						// create a couple of buttons
						button -label "button1";
						button -label "button2";
						button -label "button3";
	
					setParent ..;
				setParent ..;
	
				// create a collapsible frame layout
				frameLayout -collapsable true -label "frame2";
	
					// define the layout of controls added 
					// to the window.
					columnLayout;
	
						// create a couple of buttons
						button -label "buttonA";
						button -label "buttonB";
	
					setParent ..;
				setParent ..;

		// show the window we last created
		showWindow;
	}	
		

 

 

 

Related Documents

Windows & A quick GUI overview

Controls

Menus

Attribute Controls

Common Dialogs

 

 

[HOME] [MEL] [API]