Graphics Programs Reference
In-Depth Information
use withdifferent versions of MATLAB, you may still be better off writing
the GUI from scratch as an M-file.
To open GUIDE, select File : New : GUI from the Desktop menu bar or type
guide in the Command Window. If this is the first time you have run GUIDE,
you will next see a window that encourages you to click on “View GUIDE
Application Options dialog”. We recommend that you do so to see what your
options are, but leave the settings as is for now. After you click “OK”, the
Layout Editor will appear, containing a large white area with a grid. As with
most MATLAB windows, the Layout Editor has a tool bar with shortcuts to
many of the menu functions we describe below.
You can start building a GUI by clicking on one of the buttons to the left of
the grid, then moving to a desired location in the grid, and clicking again to
place an object on the grid. To see what type of object each button corresponds
to, move the mouse over the button but don't click; soon a yellow box with
the name of the button will appear. Once you have placed an object on the
grid, you can click and drag (hold down the left mouse button and move the
mouse) on the middle of the object to move it or click and drag on a corner to
resize the object. After you have placed several objects, you can select multiple
objects by clicking and dragging on the background grid to enclose them with
a rectangle. Then you can move the objects as a block with the mouse, or align
them by selecting Align Objects from the Layout menu.
To change properties of an object such as its color, the text within it, etc.,
you must open the Property Inspector window. To do so, you can double-click
on an object, or choose Property Inspector from the Tools menu and then
select the object you want to alter with the left mouse button. You can leave
the Property Inspector open throughout your GUIDE session and go back
and forth between it and the Layout Editor. Let's consider an example that
illustrates several of the more important properties.
Figure 8-8 shows an example of what the Layout Editor window looks like
after several objects have been placed and their properties adjusted. The
purpose of this sample GUI is to allow the user to type a MATLAB plot-
ting command, see the result appear in the same window, and modify the
graph in a few ways. Let us describe how we created the objects that make up
the GUI.
The boxes on the top row, as well as the one labeled “Set axis scaling:”, are
StaticText boxes, which the user of the GUI will not be allowed to manipulate.
To create each of them, we first clicked on the “Static Text” button — the
one to the right of the grid labeled “ TXT ” — and then clicked in the grid where
we wanted to add the text. Next, to set the text for the box we opened the
Search WWH ::




Custom Search