Lecture 10
Lecture 10
Computer Programming II
2nd class
CAD/CAM
Lecture 10
Dr. Baraa Mohsen
Graphical user interfaces (GUI)
A Graphical User Interface (GUI) is a pictorial interface that
allows the user to use an application without understanding
the language.
This is done by providing intuitive controls. The controls are
the buttons that the user clicks to obtain a determined output.
GUI is an event-driven program. This is because it acquires
input at any given time and uses the callback functions to
execute the program and give results.
We will be looking at the components that are used to
construct the graphical user interface. We will also look at
how to write the callback function of the components that
make it possible for them to execute the controls.
Matlab generates the codes for a GUI. This makes it a better
tool when designing the GUI for engineering components.
2
How to access the GUI?
You can access the GUI by typing guide in the workspace.
3
Choices window for the GUI
When Matlab GUI executes this command, a new window opens
up. This window gives various GUI templates that the user can
use for the design.
We will use a blank GUI template because it will help us apply
the basics of the GUI. On selection of the template, the
workspace opens up. This is where we implement our user
interface before writing the callback for the components.
The design will be done on the canvas using the aligned
components on the left side of the window. The names of each
component will not be visible, unless we make it so.
4
To make the names visible, we follow the procedure below:
•Click the file folder and select the preferences.
5
The components and the canvas
•Select the show names in the component palette.
•To activate these changes, click on apply then OK.
6
How to enable the name components to be visible
7
Here the components and their names are visible
To add a component to the workspace, you select it and drop
it there. The size of the components can be changed by
dragging the edges. Changing the position can be done by
double-clicking and dragging it.
10
10.Table– It is used for the addition of a spreadsheet to the
GUI. In case of a modification in the input, the callback is
executed.
11
Arrangement of components in our GUI
We then modify the components as needed. When you double-click the
component that you want to modify, a new window opens up as shown:
12
Modification window for components
13
Matlab provides a good environment for creating the
GUI. This is because it automatically generates the code
for the design of the GUI.
14