1 / 13

CS 170 – Intro to Scientific and engineering Programming

CS 170 – Intro to Scientific and engineering Programming . Graphical User Interface (GUI). GUI-based programs put the user in the driver’s seat through interactions with components of a graphical display. GUI overview. GUI’s are a collection of objects. Every object has a unique handle.

hallie
Télécharger la présentation

CS 170 – Intro to Scientific and engineering Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 InterfaceDevelopment 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 • hObjectis a number, the graphics handle, that uniquely identifies the • GUI component and its associated properties • eventdatais 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/

More Related