Making the Window do Something

Here's the new code for the window:

	string $windowName = "checkerCubeWindow";
	if (`window -exists $windowName`) deleteUI $windowName;
	window -t "3d Cube of Checkers" $windowName;
			string $dimFields = `intFieldGrp -l "XYZ dimensions" -nf 3`;
			text -l "";
			text -l "";
			rowColumnLayout -nc 2 -cw 1 150 -cw 2 100;
				text -l "";
				button -l "Create Checkers";
	window -e -wh 400 150 $windowName;
	showWindow $windowName;

See where I added the text -l ""; elements?  Those act as blank, spacer elements.
They create space in the window.
I'm also using a rowColumnLayout to better align the button.

Now for the important changes:

string $dimFields = `intFieldGrp -l "XYZ dimensions" -nf 3`;

I'm putting the return value of the intFieldGrp command into this string.
For every interface element, the help docs list the return value as:
"Full path name to the control."
What does this mean?
The window has a hierarchical structure.  For example, to get to the intFieldGrp you first go
through a window, then a columnLayout, then you get the the fields.
So the full path name is something like this:


Its like a directory structure.
We do this because now we can use the intFieldGrp as an argument to a procedure,
which will create the cubes.  You could also simply give the fields a name this way:

intFieldGrp -l "XYZ dimensions" -nf 3 dimensionFields

but then you can't be sure if there isn't already an intFieldGrp with that same name.
Putting the path-name in the variable not only takes away the task of coming up with names for
every control you make, but you're letting Maya handle the work of making sure the names
are unique.
Here is the new procedure we need to make the window work.

global proc djnUICheckerCube (string $dimFields)
	int $dimensions[] = `intFieldGrp -q -v $dimFields`;
	djnCheckerCube $dimensions[0] $dimensions[1] $dimensions[2];

The line:

int $dimensions[] = `intFieldGrp -q -v $dimFields`;

is querying the values in the intFields.  
Then we simply call djnCheckerCube and give it those values.
You may wonder why not just edit djnCheckerCube to take the name of the fields
and get the values there?  We would be using fewer procedures to do the same thing.
The problem with that is then the djnCheckerCube procedure needs the interface to function.
Using two procedures separates the functionality from the interface.  It's a more object-oriented approach,
and it also means if you want to use the procedure somewhere else, you won't have to build
a UI to fit the procedure.

Finally, edit the line creating the button to say this:
button -l "Create Checkers" -c ("djnUICheckerCube " + $dimFields);

The -c flag is used to set the command that the button executes.
We're using string concatenation to put together the name of the procedure with the variable
containing the name of the intFields.

Congratulations, the window does stuff now.
Next we'll add more features to the script.