GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.

Slides:



Advertisements
Similar presentations
Step-by-Step: Add a Graphical Hyperlink USE the Special Events Final presentation that is still open from the previous exercise. 1.Go to slide 4, and click.
Advertisements

Chapter 8 Improving the User Interface
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
CS320n –Visual Programming LabVIEW Foundations. Visual ProgrammingLabVIEW Foundations2 What We Will Do Today Hand back and review the midterm Look at.
Automating Tasks With Macros
Creating Custom Forms. 2 Design and create a custom form You can create a custom form by modifying an existing form or creating a new form. Either way,
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Introduction To Form Builder
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
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.
XP New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
Introduction to the WebBoard Terry Dennis. The WebBoard - Our Connection The WebBoard URL is
Digital Image Processing Lecture 14: GUI using Matlab
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.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Introduction to Matlab & Data Analysis
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Designing Interface Components. Components Navigation components - the user uses these components to give instructions. Input – Components that are used.
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.
Java Programming, Second Edition Chapter Five Input and Selection.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Key Applications Module Lesson 21 — Access Essentials
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room , Chris Hill, Room ,
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 5: Windows and Frames
Tutorial 51 Programming Structures Sequence - program instructions are processed, one after another, in the order in which they appear in the program Selection.
Python Programming Graphical User Interfaces Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 7 – Creating and Using Templates in a Web.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
JavaScript, Fourth Edition
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
Oct 021 Outline What is a widget? Buttons Combo boxes Text components Message boxes.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Page Designer Storyboard J. A. Fitzpatrick December 2004.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Introduction to Matlab Module #10 Page 1 Introduction to Matlab Module #10 – Creating Graphical User Interfaces Topics 1.Overview of GUI Development using.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
Lecture (7) Introduction to GUI Eng. Osama Talaat 1.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 6 1 Microsoft Office Access 2003 Tutorial 6 – Creating Custom Forms.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Excel Tutorial 8 Developing an Excel Application
Topics Graphical User Interfaces Using the tkinter Module
Graphical User Interface in MATLAB
Chapter Topics 15.1 Graphical User Interfaces
Using Templates and Library Items
Chapter 15: GUI Applications & Event-Driven Programming
Presentation transcript:

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will look at -Message boxes -Dialog boxes -UI Menus and Context menus

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 2 Message boxes There are 3 classes of message boxes Error messages Warning messages Help messages All have same functionality except for icon

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 3 Error message >>errordlg(‘message’,‘title’)

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 4 Error message An example >> errordlg(‘You have entered a wrong sign!’,‘Wrong sign’)

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 5 Warning message >>warndlg(‘message’,‘title’)

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 6 Help message >>helpdlg(‘message’,‘title’)

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 7 Summary of message boxes All message boxes have the same function Only the icon is different

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 8 Dialog boxes Dialog boxes will ask the user for input 1.Input dialog – user enters analog input 2.Question dialog – user enters discrete input of ‘Yes’, ‘No’ or ‘Cancel’

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 9 Input dialog An input dialog box enables the user to enter (analog) inputs for processing

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 10 Input dialog To generate the dialog box previously >>prompt={‘Height’,‘Width’,‘Depth’}

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 11 Input dialog >>name={‘Calculate the volume of a cuboid’}

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 12 Input dialog >>numlines=1 Will have 1 line

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 13 Input dialog >>defaultanswer={‘10’,‘10’,‘10’}

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 14 Input dialog >>options.Resize=on Not Matlab specific. Can Call any name Specific Matlab name. Cannot call anything. Enables user to resize the dialog box

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 15 Input dialog Finally, type >>answer=inputdlg(prompt,name,numlines,defaultanswer,options) ‘answer’ will return the user inputs ‘answer’ will be a cell array with 3 elements

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 16 Input dialog If the user enters Height=20; Width=30; Depth=40 Matlab will return answer = '20' '30' '40'

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 17 Input dialog To access the Height >>answer{1} To access the Width >>answer{2} To access the Depth >>answer{3} All will be in strings

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 18 Input dialog 1.‘Prompt’ and ‘Defaultanswer’ fields must have the same number of elements. 2.‘Answer’ will have same number of elements as ‘Prompt’.

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 19 Question dialog A question dialog enables the user to enter an input of ‘Yes’, ‘No’ or ‘Cancel’

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 20 Question dialog To generate the question dialog >>button=questdlg(‘Do you wish to go back?’, ‘Wrong number’) Any name you wish

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 21 Question dialog If user clicks ‘Yes’, then button=‘Yes’ If user clicks ‘No’, then button=‘No’ If user clicks ‘Cancel’, then button=‘Cancel’ To user result for processing, use the command ‘strcmp’

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 22 Question dialog >>strcmp(button,‘Yes’) Returns value of ‘1’ if button=‘Yes’. Returns value of ‘0’ if not.

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 23 Question dialog But …. you are not constrained to just ‘Yes’, ‘No’ or ‘Cancel’ You can enter up to 3 custom buttons >>button=questdlg(‘Message’, ‘Title’, ‘Button1’, ‘Button2’, ‘Button3’, ‘Default’) The last argument is always the default answer

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 24 Example 4 See Example 3. Modify it to generate an error message if any of the user inputs (height, width or depth) are negative.

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 25 Example 4 (solution) Open solution to example 3 Rename it first Front panel does not need to change Only change code

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 26 Example 4 (solution) >>if depth_num<0 || width_num<0 || height_num<0; >>errordlg('You have entered a negative number! The result is invalid. Please re-enter!','Error!'); >>set(handles.Sttxt_result,'string','Invalid'); >>else >>result=depth_num*width_num*height_num; >>result_str=num2str(result); >>set(handles.Sttxt_result,'string',result_str); >>end Outputs the result as ‘invalid’ These 3 lines the same as before

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 27 Example 4 (solution) Now test your GUI! Enter some negative numbers and see the result!

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 28 Example 5 Now modify example 4. When the user enters a negative number -Generate the error message. Ask user if wish to re-enter or close the GUI. -If wish to re-enter, let user enter using an Input Dialog -Keep repeating if user keeps entering negative numbers

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 29 Example 5 (outline solution) >>while (statement of violation) >>(ask if user wants to re-enter, Yes or No) >> >>if (user says ‘No’) >>(break ‘while’ loop and close GUI) >>else (user says ‘Yes’) >>(user Input dialog for user to re-enter) >>(obtain answers of Input dialog) >>end (end ‘if’ loop) >> >>>>end (exit ‘while’ loop)

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 30 Example 5 Obtain initial user input >>depth_num=handles.depth_num; >>width_num=handles.width_num; >>height_num=handles.height_num;

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 31 Example 5 Start ‘while’ loop >>while depth_num<0 || width_num<0 || height_num<0 >>answer=questdlg('Do you want to re-enter?', 'Error! Negative number entered!','Yes','No','Yes'); 3 arguments entered after first 2 arguments. Means there are 2 options, where ‘Yes’ is the default.

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 32 Example 5 If user says ‘No’ >> if strcmp(answer,'No'); >> close >> breaker=1; >>break Close the GUI Exit the ‘while’ loop even violation still occurs Logic variable to close GUI without error messages

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 33 Example 5 If user says ‘Yes’ >>else >> prompt={'height','width','depth'}; >> name='Please re-enter the height, width and depth'; >> numlines=1; >> defaultanswer={'0','0','0'}; >> options.Resize='on'; >> answer_reenter=inputdlg(prompt,name,numlines, defaultanswer,options); >> breaker=0;

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 34 Example 5 Obtain answers from user re-enter >> height=answer_reenter{1}; >> width=answer_reenter{2}; >> depth=answer_reenter{3}; >> height_num=str2double(height); >> width_num=str2double(width); >> depth_num=str2double(depth); >>end End ‘if’ loop End ‘while’ loop

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 35 Example 5 Do final calculation if user inputs are correct (positive) >>if breaker==1 >> nothing=0;clear nothing; >>else >> result=depth_num*width_num*height_num; >> result_str=num2str(result); >> set(handles.Sttxt_result,'string',result_str); >>end If violation occurs and user wants to exit. Then the final calculation will not be performed.

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 36 UI menus and Context menus Additional menus that help enhance the GUI

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 37 UI menus A UI menu creates a hierarchy of menus and submenus that are displayed in the figure window’s menu bar

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 38 UI menus To create a UI menu Click on the ‘Menu Editor’

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 39 UI menus The Menu Editor appears Click on ‘Menu Bar’

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 40 UI menus Then create your menu Label: Seen by user Tag: Name of Callback

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 41 UI menus -Program the Callbacks as normal. The Callbacks will be executed when the user clicks on the option. -Each ‘child’ menu item must have unique Tags, even though they have different ‘parents’.

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 42 Example 6 Re-visit the function plotter Modify it to include a UI menu so that the user can change the linestyle and colour from the menu. Also include a ‘Default’ option which is a solid line in blue.

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 43 UI Context menu A UI context menu appears when the user right-clicks a graphics object

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 44 UI Context menus To create a UI Context menu Click on the ‘Menu Editor’

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 45 UI menus The Menu Editor appears Click on ‘Context menus’

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 46 UI Context menus Create your context menu Tag: Name of Callback Label: Seen by user Name of the Context menu

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 47 UI Context menus -Give a name to the graphics object which the Context menu is attached to -Link the graphics object to the Context menu >>hline=plot(u,y); >>handles.hline=hline; >>set(hline,'UIContextmenu',handles.LineCmenu); Plot the graph and give it a name Name of the Context menu Matlab name Line name

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 48 UI Context menus -Program the other Callbacks as usual

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 49 Example 7 Revisit the function plotter Modify it to include a context menu such that the user can specify line style and colour. Also include the ‘Default’ option.

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 50 Example 8 Create a GUI with the following front panel

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 51 Example 8 -Have 2 (exclusive) choices: Plot 1 and Plot 2 -Plot 1 will produce y=a*sin(b*t+c) in red -Plot 2 will produce y=sin(a*t)+sin(c*t) in blue

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 52 Example 8 -The sliders should vary between 0 and 1

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 53 Example 8b -Now, add an Edit Text beside each slider. The user can enter the value using Edit Text or slider. -When slider changes value, it should be displayed in Edit Text -When user enters value in Edit Text the slider should change correspondingly

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 54 Example 8c If user enters value in Edit Text that is out of range of slider, the slider will disappear Modify the GUI so that it will generate an error message and not allow the slider to disappear

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 55 Example 8d Create context menus for the plots, in terms of line styles and colours

GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 56 Conclusion -Message boxes: Error, help, warning messages -Dialog boxes: Input, question dialog boxes -Menus and Context menus