Creating Graphical User Interfaces    

Set Properties for the GUI Components

To set the properties of each GUI component, select the Property Inspector from the View menu to display the Property Inspector. When you select a component in the Layout Editor, the Property Inspector displays the component's properties. If no component is selected, the Property Inspector displays the properties of the GUI figure, as shown in the following figure.

Name Property

Scroll down the list of properties until you come to Name. In the field next to Name, type Simple GUI, as shown in the following figure. This is the title that is displayed at the top of the GUI.

String Property

You can set the label in a GUI component by its String property. For example, to set the label of the top push button, select the push button in the Layout Editor and then scroll down in the Property Inspector until you come to String. In the field to the right of String, change Push Button to Surf, as shown in the following figure.

You can view the change by clicking the Layout Editor. Similarly, change the String property of the middle push button to Mesh, the bottom push button to Contour, and the Static Text to Select Data.

Pop-up Menu Items.   To set pop-up menu items, select the popup menu in the Layout Editor. In the Property Inspector, click the icon next to String. This opens the String property edit box. Delete Popup Menu in the String property edit box, and type peaks, membrane, and sinc on three separate lines, as shown in the following figure:

When you click on the Layout Editor, the GUI appears as in the following figure.

Callback and Tag Properties

The Callback property specifies the callback - the function in the GUI M-file that gets called when a user activates the component, for example, by clicking a push button.

When you first add a component to the layout, its Callback property is set to the string %automatic, as shown in the following figure.

When you save or run the GUI, GUIDE converts this string to one that calls a function in the generated M-file. GUIDE uses the component's Tag property to to associate the component with the function. By default, Tag is set to a generic label such as pushbutton1. You might want to change the Tag property of the pop-up menu to a more descriptive label, such as plot_popup, as shown in the following figure, before you save or run the GUI for the first time:

When you save or run the GUI, GUIDE sets the pop-up menu Callback property to plot_popup_Callback. If you later change the Tag, GUIDE updates the Callback property to match the new Tag - see Changing Component Tag Properties.

Similarly, change the push button tags to surf_pushbutton, mesh_pushbutton, and contour_pushbutton.

To learn more, see Setting Component Properties - The Property Inspector


  Programming the GUI Opening the GUI M-File