MATLAB Creating Graphical User Interfaces

(Barry) #1
GUIDE Templates

To use a template:


1 Select a template in the left pane. A preview displays in the right pane.


2 Optionally, name your UI now by selecting Save new figure as and typing the
name in the field to the right. GUIDE saves the UI before opening it in the Layout
Editor. If you choose not to name the UI at this point, GUIDE prompts you to save it
and give it a name the first time you run your program.


3 Click OK to open the UI template in the Layout Editor.


Template Descriptions


GUIDE provides four fully functional templates. They are described in the following
sections:



  • “Blank GUI” on page 6- 3

  • “GUI with Uicontrols” on page 6- 4

  • “GUI with Axes and Menu” on page 6- 6

  • “Modal Question Dialog” on page 6- 8


“Out of the box,” none of the UI templates include a menu bar or a toolbar. Neither can
they dock in the MATLAB desktop. You can, however, override these GUIDE defaults to
provide and customize these controls. See the sections “Create Menus for GUIDE UIs” on
page 6-91 and “Create Toolbars for GUIDE UIs” on page 6-108 for details.


NoteTo see how the templates work, you can view their code and look at their callbacks.
You can also modify the callbacks for your own purposes. To view the code file for any of


these templates, open the template in the Layout Editor and click the Editor button
on the toolbar.


Blank GUI


The following figure shows an example of this template.

Free download pdf