Creating Graphical User Interfaces Previous page   Next Page

Files for Programmatically Created GUIs

When you create a GUI programmatically, these are two approaches you can use to structure your GUI files:

Single M-File Using GUIDE as a Model

In this approach, the file is ordered in the following sections:

  1. Comments that are displayed in response to the MATLAB help command.
  2. Command to make the figure invisible so the user can't see it being constructed.
  3. Construction of components and menus. Don't set the callback properties yet.
  4. Command to generate a structure of component handles to pass to the callbacks.
  5. Associating callbacks with components by setting the component callback properties. See Associating Callbacks with Components for more information.
  6. Initialization tasks. Make the figure visible.
  7. Callbacks for the components. See Callbacks in Programmatically Created GUIs for information about the callbacks.

This is a template for such a file.

Single M-File Using Nested Funtions

In this approach, the file is ordered in the following sections. For general information about nested functions, see Nested Functions in the MATLAB documentation.

  1. Comments that are displayed in response to the MATLAB help command.
  2. Command to make the figure invisible so the user can't see it being constructed.
  3. Construction of components and menus. Set each component's callback properties as you construct the component. See Associating Callbacks with Components for more information.
  4. Initialization tasks. Make the figure visible.
  5. Callbacks for the components. Define them as nested functions under the main function. These callbacks automatically have access to all component handles because the handles are defined at a higher level. See Callbacks in Programmatically Created GUIs for information about the callbacks.

This is a template for such a file.


Previous page  GUIDE M-Files and FIG-Files Associating Callbacks with Components Next page

© 1994-2005 The MathWorks, Inc.