Basic GUI (Pop-up menu)

Basic GUI (Pop-up menu)

Final GUI for this tutorial

Initializing GUIDE (GUI Creator)

1. Open up MATLAB. Go to the command window and type in guide

2. Choose the first option Blank GUI (Default)

3. You should now see the following screen.

4. For the adder GUI, we will need the following components

Add an Edit Text component to the GUI figure.

Add a Pop-up Menu component onto the GUI figure.

5. Double click the Edit Text component to bring up the Property Inspector.

Change the String property to Testing!!!, and change the Tag property to testing_staticText as shown in the figure below:

6. Modify the properties of the Pop-up Menu component.

Click on the icon on the String property line as shown below.

7. After clicking on the icon, you should now see the following window.

Fill in the window as shown below:

5. The figure should look like after you add the components and modify them.

6. Add some Static Text components to add some description tags to the GUI.

Modify their text by double clicking on the component and changing the String property.

7. Save your GUI wherever you please with your desired filename.


Writing the Code for the GUI Callbacks

8. Open up the .m file that was automatically generated when you saved your GUI.

9. In the MATLAB editor, click on the icon (f), which will bring up a list of the functions within the .m file.

Select popupmenu1_Callback.

10. Add the following code to the function:

Copy and paste the code

switch get (handles.popupmenu1, ‘Value’)
case 1
set(handles.testing_staticText,’FontSize’,8);
case 2
set(handles.testing_staticText,’FontSize’,10);
case 3
set(handles.testing_staticText,’FontSize’,12);
case 4
set(handles.testing_staticText,’FontSize’,14);
case 5
set(handles.testing_staticText,’FontSize’,16);
otherwise
end

11) You can click BUTTON PLAY on the to launch the GUI.

Go ahead and try selecting different font sizes.

END

izzad Ramli

Comments are closed.