Download presentation
Presentation is loading. Please wait.
Published bySamantha Paul Modified over 9 years ago
1
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING
2
Graphical User Interface (GUI) GUI-based programs put the user in the driver’s seat through interactions with components of a graphical display
3
GUI overview GUI’s are a collection of objects. Every object has a unique handle. Every object has properties. The user can alter these properties at design time.
4
MATLAB’s Graphical User Interface Development Environment (GUIDE)
5
Saving the GUI layout When our energyGUI layout is saved the first time, MATLAB generates two files: energyGUI.fig: Layout Editor window with the developing GUI, which can be modified later by entering >> guide energyGUI.fig energyGUI.m: file that contains code to create the GUI display
6
Property Inspector
7
GUI Handles Every object in the GUI will have an unique handle (name). The handle allows developers to access the objects properties.
8
How do we obtain handles? fig = openfig('myFirstGUI.fig'); %loads the figure handles = guihandles(fig); % Update handles structure guidata(hObject, handles);
9
Inputs to GUI functions hObject is a number, the graphics handle, that uniquely identifies the GUI component and its associated properties eventdata is not used in the current version of MATLAB handles is a structure that contains information that needs to be shared between functions in this file. Initially it contains a field for each GUI component created, using Tag property as name: handles.axes1 handles.sourceMenu handles.sourceToggle handles.titleLabel handles.titleBox handles.widthCheckbox handles.plotButton handles.closeButton handles.figure1
10
Once we have the ‘Handle’ how do we change properties ? %Set data to current value handles.peaks = peaks(35); handles.current_data = handles.peaks; surf(handles.current_data); % Choose default command line output for myFirstGUI handles.output = hObject;
11
Callback functions For each component, the header of a Callback function is created. These functions are invoked automatically when the user interacts with the corresponding component
12
QUESTIONS??
13
Resources Lecture slides CS112, Ellen Hildreth, http://cs.wellesley.edu/~cs112/ http://cs.wellesley.edu/~cs112/
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.