Graphic User Interfaces (GUI) GUI provides a way to interact friendly with possibly complex programs. There are two types of GUI: - MDI: multiple document.

Slides:



Advertisements
Similar presentations
Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
1 How to create GUI's in MatLAB Rigo Dicochea. 2 Introduction Graphical User Interface (GUI) MatLab provides Graphical User Interface Development Environment(GUIDE)
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Matlab GUIs Making Matlab Interactive. Today’s topics What is a GUI? How does a GUI work? Where do you begin? Ways to build MATLAB GUIs.
Chapter 4 Dreamweaver: Part II The Web Warrior Guide to Web Design Technologies.
Programming a GUI Hanan sedaghat pisheh. For calling GUI, we need a function with no inputs or outputs First We create a m.file m file has the same name.
Chapter 3 Dreamweaver: Part I The Web Warrior Guide to Web Design Technologies.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 4 1 Microsoft Office FrontPage 2003 Tutorial 4 – Using Shared Borders and Themes.
CHAPTER 9 Introducing Microsoft Office Learning Objectives Start Office programs and explore common elements Use the Ribbon Work with files Use.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
A short intermission about function handles and cell arrays A MATLAB function may be referenced by a handle. >> sphere(100)
Introduction to the Graphical User Interface (GUI) in MATLAB
Matlab GUIs GUIDE.
IE 411/511: Visual Programming for Industrial Applications
CHAPTER 9 Introducing Microsoft Office Learning Objectives Start Office programs and explore common elements Use the Ribbon Work with files Use.
Introduction to Matlab & Data Analysis
GUI Input and Output Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
JAOIT 8.  Dreamweaver is a program for creating web pages and managing websites without having to type HTML code.  WYSIWYG – What you see is what you.
Project 2 Adding Web Pages, Links, and Images Dreamweaver MX 2004 Concepts and Techniques.
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
function varargout = MovieJoiner(varargin) % MOVIEJOINER M-file for MovieJoiner.fig % MOVIEJOINER, by itself, creates a new MOVIEJOINER or raises the.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
Introduction to MATLAB Damon Tomlin February 22, 2008 Lecture 3: Data Visualization & User Interfaces.
Chapter 1 Creating a Dreamweaver Web Page and Local Site
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 3.1 Test-Driving the Welcome Application 3.2.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Microsoft Access 2000 Presentation 3 Creating Databases Part II (Creating Forms)
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
The Hong Kong Polytechnic University Industrial Centre 1 MatLAB Lesson 9 : Introduction to GUI & Revision Edward Cheung Room W311g.
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
EGR 115 Introduction to Computing for Engineers
Introduction to Matlab Module #10 Page 1 Introduction to Matlab Module #10 – Creating Graphical User Interfaces Topics 1.Overview of GUI Development using.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Lecture (7) Introduction to GUI Eng. Osama Talaat 1.
Data Analysis GUI Documentation guide. Terminology GUI – Graphical User Interface Log-File – File containing data of interest which is generated by user’s.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Adobe ® Photoshop ® CS6 Chapter 1 Editing a Photo.
 You won’t write a single line of program code.  Instead, you’ll use visual programming techniques.  Visual Studio processes your actions (such as mouse.
Graphical User Interface in MATLAB
Learning the Basics – Lesson 1
Chapter 2 – Introduction to the Visual Studio .NET IDE
3.01 Apply Controls Associated With Visual Studio Form
3.01 Apply Controls Associated With Visual Studio Form
Chap 7. Building Java Graphical User Interfaces
More on Graphical User Interfaces
Graphical User Interfaces -- Introduction
Introducing Microsoft Office 2010
Chapter 2 Adding Web Pages, Links, and Images
Chapter 2 – Introduction to the Visual Studio .NET IDE
Tutorial 6 Creating Dynamic Pages
Chapter 4 Enhancing the Graphical User Interface
Presentation transcript:

Graphic User Interfaces (GUI) GUI provides a way to interact friendly with possibly complex programs. There are two types of GUI: - MDI: multiple document interfaces. - SDI: single document interfaces. GUIs provide components that allow the interaction with the underly programs/functions/dataset. Main components: menus, toolbars, axes, push buttons, radio buttons, list box y sliders, etc. GUIs provide mechanisms to manage/save user information

Example of GUI using: - Three buttons that provide the main interaction with the GUI. - Static text component. - Pop-up menu: contains a list of different functions to plot. - Axes component: provides the graphic output How does a GUI work? Each component, even the main figure, is associated with special functions called callbacks. Callbacks are executed automatically at every action Callbacks input parameters disclose exactly the type of action

Dialog box Matlab functionalities dialog - Create dialog figure. errordlg - Error dialog box. helpdlg - Help dialog box. inputdlg - Input dialog box. listdlg - List selection dialog box. menu - Generate a menu of choices for user input. msgbox - Message box. questdlg - Question dialog box. uigetdir - Standard open directory dialog box uigetfile - Standard open file dialog box. uigetpref - question dialog box with preference support uiputfile - Standard save file dialog box. uiopen - Present file selection dialog with appropriate file filters. uisave - GUI Helper function for SAVE uisetcolor - Color selection dialog box. uisetfont - Font selection dialog box. waitbar - Display wait bar. warndlg - Warning dialog box. export2wsdlg - Exports variables to the workspace printdlg - Print dialog box printpreview - Display preview of figure to be printed

Creating a simple GUI Use the guide function with default Blank GUI selection. Visualize the component names using the Preferences Matlab dialog: File  Preferences, then choose tab GUIDE and select option “Show names in component palette”. redimensionar

Select and drag each required component Push Buttons Axes Static Text Pop-up Menu Align the components for a better appearance First select components by pressing Ctrl button. Then select Tools  Align Objects.

Component customization Change component properties: View  Property Inspector Select string property for each component, modify the content or type in the component name according to the particular case. Example: for pop-up menu introduce the texts “Peaks”, “Membrane” and “Sinc” in separate lines.

The “…OpeningFcn” entry in the toolbar, under functions list (V7 V8 allows to customize (load initial data, appearance) the GUI before opening. Creation and execution of a GUI Associated to the GUI there are two files: (1) binary.fig extension that contain GUI content for design, (2) ascii.m extension with GUI code including callbacks functions. After designing the GUI save and execute the code (button ) Example: change GUI background color.

Creating a functional GUI Insert code for each “callback” function to attend the GUI demands, the callback number of inputs are fixed to 4: - hObjecthandle of the main figure. - eventdatareserved for future versions. - handlesstruct with all the components’ handle. Alternatively, it can contain useful information - varargin cell-array that allow in a tricky way the input of more than 4 parameters. handles allows to interact with all the GUI controls and that users can input information and thus interact with the GUI. If some “callback” function modify the handles struct, it must updated it at the GUI level to avoid loss of information: guidata(hObject, handles)

% --- Executes just before simple_gui is made visible. function simple_gui_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to simple_gui (see VARARGIN)... % Choose default command line % output for simple_gui handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes simple_gui wait % for user response (see UIRESUME) % uiwait(handles.figure1); % Create the data to plot handles.peaks=peaks(35); handles.membrane=membrane; [x,y] = meshgrid(-8:.5:8); r = sqrt(x.^2+y.^2) + eps; sinc = sin(r)./r; handles.sinc = sinc; % Set the current data value. handles.current_data =... handles.peaks; surf(handles.current_data Add this initialization code to the “…openingFcn” callback

Adding functionalities… The pop-up menu allow users to select among different graphics. Right click on top of the pop- up menu to create callback function and insert code: View Callbacks  Callback

Pop-up menu callback % Determine the selected data set str = get(hObject, 'String'); val = get(hObject,'Value'); % Set current data to the selected % data set switch str{val}; case 'Peaks' handles.current_data =... handles.peaks; case 'Membrane' handles.current_data =... handles.membrane; case 'Sinc' handles.current_data =... handles.sinc; end % Save the handles structure guidata(hObject,handles) Surf button callback surf(handles.current_data); Mesh button callback mesh(handles.current_data); Contour button callback contour(handles.current_data); “String” and “Value” allow to access the user selection Functions get and set allow access and modification of property values.

GUI programming without using GUIDE Matlab GUIs can be created completely straighforward: f = figure('visible', 'off', 'position', [360,500,450,285]); Call figure to create the GUI frame and use “visible” and “position” properties to set figure visibility and position. hsurf = uicontrol('style', 'pushbutton',... 'string', 'Surf', 'position', [ ]); hpopup = uicontrol('style', 'popupmenu', 'string', {'Peaks',... 'Membrane', 'Sinc'}, 'position', [ ]); Call uicontrol to create components and use “style” and “string” properties to select the type of control and customized it. ha = axes('units', 'pixels', 'position', [ ]); Call axes to create graphical component and use “units” to select the units that should be accounted for axes position.

function simple_gui % Select a data set from the pop-up menu, then click one of the plot-type push % buttons. Clicking the button plots the selected data in the axes. % Create and hide the GUI as it is being constructed. hfig = figure('visible', 'off', 'position', [ ]); % Construct the components. hsurf = uicontrol('style', 'pushbutton', 'string', 'Surf',... 'position', [ ]); hmesh = uicontrol('style', 'pushbutton', 'string', 'Mesh',... 'position', [ ]); hcontour = uicontrol('style', 'pushbutton', 'string', 'Countour',... 'position', [ ]); htext = uicontrol('style', 'text', 'string', 'Select Data',... 'position', [ ]); hpopup = uicontrol('style', 'popupmenu', 'string', {'Peaks','Membrane','Sinc'},... 'position', [ ]); haxes = axes('units', 'pixels', 'position', [ ]); align([hsurf hmesh hcontour htext hpopup], 'center', 'none'); % Make the GUI visible set(hfig, 'Visible', 'on'); end Align the components automatically Changes the figure visibility

Programming the GUI... Resizing the GUI can have undesirable results. There are two choices: Change components’s dimension units to normalized in order to obtain a better result. After that, the bottom-left and upper-right corners have positions (0,0) and (1,1) respectively. set([f hsurf hmesh hcontour htext hpopup haxes], 'units', 'normalized'); You can also change the GUI presentation name and remove the toolbar: set(hfig, 'name', 'Simple GUI'); set(hfig, 'NumberTitle', 'off'); set(hfig, 'MenuBar', 'none'); Call movegui GUI location to a new position: movegui(f, 'center');

The callbacks functions can be programmed as nested functions to produce a more straightforward code function pmenu_Callback(source,... eventdata) % Determine the selected data set. str = get(source, 'String'); val = get(source,'Value'); % Set current data. switch str{val}; case 'Peaks' current_data = peaks_data; case 'Membrane' current_data = membrane_data; case 'Sinc' current_data = sinc_data; end function sbutton_Callback(source, … eventdata) surf(current_data); end function mbutton_Callback(source, … eventdata) mesh(current_data); end function cbutton_Callback(source, … eventdata) contour(current_data); end You can link the previous nested functions to corresponding components by using the 'callback’ property. For example: hsurf = uicontrol(..., 'callback',

More about components Toggle Button : Create using uicontrol('style', 'togglebutton',...). They are used to represent two states (down/up). If they are contained inside a Button Group component, then only one can be active at the same time. Check Box : Create using uicontrol('style', 'checkbox',...). Very similar to Toggle Button it can be selected or not, but you can have several selected at the same time. Radio Button : Create using uicontrol('style', 'radiobutton',...). The behavior is identical to Toggle Buttons’. Edit Text : Create using uicontrol('style', 'edit',...). It allows users to enter input as strings. If you intend to enter a number as number use the function str2num to read the string content. Slider : Create using uicontrol('style', 'slider',...). They can be horizontal or vertical and are used to slide content that is not currently visible.

% Create the button group. h = uibuttongroup('visible', 'off', 'Position', [ ]); % Create three radio buttons in the button group. u0 = uicontrol('Style', 'Radio', 'String', 'Option 1',... 'parent', h, 'pos', [ ], 'HandleVisibility', 'off'); u1 = uicontrol('Style', 'Radio', 'String', 'Option 2',... 'parent', h, 'pos', [ ], 'HandleVisibility', 'off'); u2 = uicontrol('Style', 'Radio', 'String', 'Option 3',... 'parent', h, 'pos', [ ], 'HandleVisibility', 'off'); % Initialize some button group properties. set(h, set(h, 'SelectedObject', []); % No selection set(h, 'Visible', 'on'); List Box : Create using uicontrol('style', 'listbox',...). Visualize several options allowing to users the selection of one or several simultaneously. Button Group : It is like a panel or container that is used to provide an automatic exclusive behavior to contained Radio and Toggle buttons. Example:

function selcbk(source, eventdata) disp(source); disp([eventdata.EventName, ' ', get(eventdata.OldValue, 'String'),... ' ', get(eventdata.NewValue, 'String')]); disp(get(get(source, 'SelectedObject'), 'String')) Other commonly used component properties: - enable: 'on' ('off') indicate that state is active (inactive). - max: Scalar value, max=1 by default. - min: Scalar value, min=0 by default.. - position: Vector of 4 elements, i.e. [distance from left, distance from right, witdh, height]. - string: Allow to read content. It can be an string or a cell-array of strings. - value: scalar or vector, the output depend on the component and user action. Other components and the use of ActiveX components?

You can also add an image to a button img = rand(16,64,3); set(handles.pushbutton1, 'CData', img); Use of uiwait - uiresume f = figure; h = uicontrol('Position', [ ], 'String', 'Continue',... 'Callback', 'uiresume(gcbf)'); disp('This will print immediately'); uiwait(gcf); disp('This will print after you click Continue'); close(f); Use of waitbar - pause h = waitbar(0,'Please wait...'); for it = 1:1000, % computation here pause(0.01); waitbar(it/1000, h) end guidlg_time('inicializar'); for it = 1:1000, % computation here pause(0.01); guidlg_time(it/1000); end guidlg_time('finalizar');

Many Web sites and commercial publications such as the following provide guidelines for designing GUIs: AskTog — Essays on good design and a list of First Principles for good user interface design. The author, Tognazzini, is a well-respected user interface designer. Galitz, Wilbert, O., Essential Guide to User InterfaceDesign. Wiley, New York, NY, GUI Design Handbook — A detailed guide to the use of GUI controls. Johnson, J., GUI Bloopers: Don'ts and Do's for Software Developers and Web Designers. Morgan Kaufmann, San Francisco, CA, Usability Glossary — An extensive glossary of terms related to GUI design, usability, and related topics. UsabilityNet — Covers design principles, user-centered design, and other usability and design-related topics.