Basic GUI (Pop-up menu)

Basic GUI (Pop-up menu)

Final GUI for this tutorial

Screenshot-2021-09-14-at-4.08.15-PM Basic GUI (Pop-up menu)

Initializing GUIDE (GUI Creator)

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

Screenshot-2021-09-14-at-10.47.33-AM Basic GUI (Pop-up menu)

2. Choose the first option Blank GUI (Default)

Screenshot-2021-09-14-at-10.48.46-AM Basic GUI (Pop-up menu)

3. You should now see the following screen.

Screenshot-2021-09-14-at-10.49.31-AM Basic GUI (Pop-up menu)

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.

Screenshot-2021-09-14-at-4.10.54-PM Basic GUI (Pop-up menu)

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:

Screenshot-2021-09-14-at-4.15.16-PM Basic GUI (Pop-up menu)

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

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

Screenshot-2021-09-14-at-4.15.56-PM Basic GUI (Pop-up menu)

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

Fill in the window as shown below:

Screenshot-2021-09-14-at-4.16.02-PM Basic GUI (Pop-up menu)

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

Screenshot-2021-09-14-at-4.28.48-PM Basic GUI (Pop-up menu)

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.

Screenshot-2021-09-14-at-4.29.39-PM Basic GUI (Pop-up menu)

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.

Screenshot-2021-09-14-at-4.35.24-PM Basic GUI (Pop-up menu)

10. Add the following code to the function:

Screenshot-2021-09-14-at-4.36.26-PM Basic GUI (Pop-up menu)

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.

Screenshot-2021-09-14-at-4.40.02-PM Basic GUI (Pop-up menu)

Go ahead and try selecting different font sizes.

Screenshot-2021-09-14-at-4.42.23-PM Basic GUI (Pop-up menu)

END

Share this content:

izzad Ramli

Comments are closed.