GUI Input and Output. Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University



Similar documents
MATLAB GUIs. We conclude our brief overview of MATLAB by looking at : Brief introduction to MATLAB GUI building. Back Close CM0268 MATLAB DSP GRAPHICS

Input - Output dialog commands and boxes

AMATH 352 Lecture 3 MATLAB Tutorial Starting MATLAB Entering Variables

MATLAB 7 Creating Graphical User Interfaces

Beginner s Matlab Tutorial

MATLAB. Creating Graphical User Interfaces Version 6. The Language of Technical Computing. Computation. Visualization. Programming

Introduction to Matlab

Using Adobe Dreamweaver CS4 (10.0)

Introduction to Graphical User Interface (GUI) MATLAB 6.5

Introduction. Chapter 1

Data Tool Platform SQL Development Tools

State of Michigan Data Exchange Gateway. Web-Interface Users Guide

Create a New Database in Access 2010

Work with the MiniBase App

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

KaleidaGraph Quick Start Guide

DataPA OpenAnalytics End User Training

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Appendix A How to create a data-sharing lab

First Bytes Programming Lab 2

Business Objects Version 5 : Introduction

Evaluator s Guide. PC-Duo Enterprise HelpDesk v5.0. Copyright 2006 Vector Networks Ltd and MetaQuest Software Inc. All rights reserved.

USER GUIDE. Unit 2: Synergy. Chapter 2: Using Schoolwires Synergy

FIRST STEPS WITH SCILAB

Web Intelligence User Guide

Lesson 07: MS ACCESS - Handout. Introduction to database (30 mins)

Create Mailing Labels from an Electronic File

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3

User Manual V1.3. NCB File /alahlincb

Access II 2007 Workshop

User s Manual CAREpoint EMS Workstation D-Scribe Reporting System

DiskPulse DISK CHANGE MONITOR

SA-9600 Surface Area Software Manual

WebSphere Business Monitor V6.2 Business space dashboards

Personal Portfolios on Blackboard

MICROSOFT OFFICE ACCESS NEW FEATURES

Microsoft Access Database

Visual Basic Programming. An Introduction

SafeGuard PrivateCrypto 2.40 help

Switching from PC SAS to SAS Enterprise Guide Zhengxin (Cindy) Yang, inventiv Health Clinical, Princeton, NJ

SAS BI Dashboard 4.3. User's Guide. SAS Documentation

Recording Supervisor Manual Presence Software

Basic Excel Handbook

ArcGIS Tutorial: Adding Attribute Data

Appointment Scheduler

Tutorial 2: Reading and Manipulating Files Jason Pienaar and Tom Miller

Computer Training Centre University College Cork. Excel 2013 Pivot Tables

Scribe Online Integration Services (IS) Tutorial

Microsoft Access 2007 Introduction

Module One: Getting Started Opening Outlook Setting Up Outlook for the First Time Understanding the Interface...

G563 Quantitative Paleontology. SQL databases. An introduction. Department of Geological Sciences Indiana University. (c) 2012, P.

Reporting Manual. Prepared by. NUIT Support Center Northwestern University

Graphic Objects and Loading Them into TGF2/MMF2

Market Pricing Override

WebSphere Business Monitor V7.0 Business space dashboards

Office of History. Using Code ZH Document Management System

Getting Started with IntelleView POS Administrator Software

Microsoft Excel Tips & Tricks

Managing Expense Reports Program Administrators and Approvers

BusinessObjects: General Report Writing for Version 5

Create Charts in Excel

Alarms & Events Plug-In Help Kepware, Inc.

Help File. Version February, MetaDigger for PC

Excel 2010: Create your first spreadsheet

IBM FileNet eforms Designer

SPSS for Windows importing and exporting data

How do I share a file with a friend or trusted associate?

Differences in Use between Calc and Excel

PIC 10A. Lecture 7: Graphics II and intro to the if statement

SHAREPOINT 2010 FOUNDATION FOR END USERS

Working with Excel in Origin

File Manager Pro User Guide. Version 3.0

Introduction to MATLAB (Basics) Reference from: Azernikov Sergei

EMC Documentum Webtop

Access Queries (Office 2003)

Microsoft Access Introduction

Appendix: Tutorial Introduction to MATLAB

Importing and Exporting With SPSS for Windows 17 TUT 117

Advanced BIAR Participant Guide

Discoverer Training Guide

MATLAB Functions. function [Out_1,Out_2,,Out_N] = function_name(in_1,in_2,,in_m)

INFOPATH FORMS FOR OUTLOOK, SHAREPOINT, OR THE WEB

MATLAB DFS. Interface Library. User Guide

Olathe District Schools 1 of 11 GroupWise 7

Importing TSM Data into Microsoft Excel using Microsoft Query

Microsoft Access 2010 handout

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

User's Guide. Using RFDBManager. For 433 MHz / 2.4 GHz RF. Version

Utilities ComCash

Developing Website Using Tools

Basic Concepts in Matlab

Configuration Manager

Attix5 Pro Server Edition

Topography of an Origin Project and Workspace

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Note: With v3.2, the DocuSign Fetch application was renamed DocuSign Retrieve.

Technical Documentation Version 6.7. Slots

Setting up Auto Import/Export for Version 7

Transcription:

GUI Input and Output Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University

GUI Input and Output 2010-13 Greg Reese. All rights reserved 2

Terminology User I/O GUI: Graphical User Interface I/O: Input or Output Two ways to do user I/O, i.e., get input from the user or show output to the user) 1. In the command-line window 2. Using a GUI 3

Command-line I/O Command line advantages Easy Can use if MATLAB graphics not available Automatically converts text input to number 4

Graphical I/O Graphical User Interface (GUI) advantages Fairly easy Modern (current users familiar with it) Clear, convenient displays Fun! 5

Pre-defined dialog boxes dialog errordlg export2wsdlg helpdlg inputdlg listdlg msgbox printdlg printpreview questdlg uigetdir uigetfile uigetpref uiopen uiputfile uisave uisetcolor uisetfont waitbar warndlg Create and display empty dialog box Create and open error dialog box Export variables to workspace Create and open help dialog box Create and open input dialog box Create and open list-selection dialog box Create and open message box Print dialog box Preview figure to print Create and open question dialog box Open standard dialog box for selecting directory Open standard dialog box for retrieving files Specify and conditionally open dialog box according to user preference Interactively select file to open and load data Open standard dialog box for saving files Interactively save workspace variables to MAT-file Open standard dialog box for setting object's ColorSpec Open standard dialog box for setting object's font characteristics Open or update wait bar dialog box Open warning dialog box (From MATLAB documentation) 6

Pre-defined dialog boxes Most pre-defined dialog boxes are for getting input from the user dialog export2wsdlg inputdlg listdlg printdlg questdlg uigetdir uigetfile uigetpref uiopen uiputfile uisave uisetcolor uisetfont Create and display empty dialog box Export variables to workspace Create and open input dialog box Create and open list-selection dialog box Print dialog box Create and open question dialog box Open standard dialog box for selecting directory Open standard dialog box for retrieving files Specify and conditionally open dialog box according to user preference Interactively select file to open and load data Open standard dialog box for saving files Interactively save workspace variables to MAT-file Open standard dialog box for setting object's ColorSpec Open standard dialog box for setting object's font characteristics 7

Pre-defined dialog boxes Some pre-defined dialog boxes are for showing output to the user errordlg helpdlg msgbox printpreview waitbar warndlg Create and open error dialog box Create and open help dialog box Create and open message box Preview figure to print Open or update wait bar dialog box Open warning dialog box 8

Pre-defined dialog boxes Pre-defined dialog boxes are either modal or non-modal (modeless) Modal dialog box Prevents user from going to any other window in program (including command line) until user closes box If used in script or function, code keeps running! Use uiwait() to pause code Examples: open file dialog, get user input dialog 9

Pre-defined dialog boxes Non-modal (modeless) dialog box Permits user to go to any other window in program (including command line) If used in script or function, code keeps running! Use uiwait() to pause code Examples: error dialog, message dialog 10

Input dialog box answer = inputdlg(prompt) prompt is a text string or cell array containing prompts answer is cell array, same size as prompt Dialog box is modal GUI input (Text strings and cell arrays discussed in other lectures) 11

Example GUI input >> name=inputdlg( 'Full name' ) name = 'Greg Reese' >> whos name Name Size Bytes Class Attributes name 1x1 132 cell >> n = name{1} n = Greg Reese >> whos n Name Size Bytes Class Attributes n 1x10 20 char 12

Canceling returns empty cell array >> name=inputdlg('full name' ) name = {} >> isempty( name ) ans = 1 GUI input 13

GUI input Numerals returned as text, i.e., not converted to numbers Use str2double or str2num to convert >> weight=inputdlg('weight' ) weight = '212.5' >> w = weight{1}; >> whos w Name Size Bytes Class Attributes w 1x5 10 char >> w = str2double( weight{1} ); >> whos w Name Size Bytes Class Attributes w 1x1 8 double 14

Try it Put up an input box that asks for the user's car manufacturer and display the string "Your car was made by xxx" where "xxx" is the name the user entered. Hint: concatenate the first part of the sentence with the user's response and display the result with disp() >> name = inputdlg( 'Your car''s manufacturer' ) name = 'Toyota' GUI input >> disp( [ 'Your car was made by ' name{1} ] ); Your car was made by Toyota Note braces 15

GUI input str2double() Call as x = str2double('str') str is a string that is text representation of one real or complex number x is a double-precision number if str doesn't represent a number, x is NaN Call as x = str2double( C ) C is a cell array of strings x is an array of double-precision numbers x is same size as C 16

GUI input str2num() Call as x = str2num('str') str is a string that is text representation of a scalar or matrix of real or complex numbers x is same size as matrix in str if str not correct, x is empty matrix str can contain one or more numbers separated by spaces, commas, or semicolons String Input Numeric Output Output Class Examples from MATLAB help '500' 500 1-by-1 scalar double '500 250 125 67' 500, 250, 125, 67 1-by-4 row vector of double '500; 250; 125; 62.5' 500.0000 250.0000 125.0000 62.5000 '1 23 6 21; 53:56' 1 23 6 21 53 54 55 56 4-by-1 column vector of double 2-by-5 matrix of double '12e-3 5.9e-3' 0.0120 0.0059 vector of double 'uint16(500)' 500 16 bit unsigned integer 17

GUI input Variation 1 - add title to box answer = inputdlg(prompt,dlg_title) dlg_title title of dialog box >> name = inputdlg( 'Name', 'Character Information' ) name = 'Suleiman the Magnificent' Title doesn't appear fully in Windows 7 (MATLAB bug!) 18

Variation 2 - number of entered lines answer = inputdlg(prompt,dlg_title,num_lines) num_lines number of lines user can enter See Help if have multiple prompts >> name = inputdlg( 'Names', 'Character Information', 3 ) name = [3x18 char] >> name{1} ans = Voldemort Dark Lord Tom Marvolo Riddle GUI input 19

Variation 3 - default value answer = inputdlg(prompt,dlg_title, num_lines,defans) defans default answer to display See Help if have multiple prompts >> name = inputdlg( 'Favorite character', 'Character Information', 1, 'Hermione' )??? Error using ==> inputdlg at 113 Default Answer must be a cell array of strings. >> name = inputdlg( 'Favorite character', 'Character Information', 1, {'Hermione'} ) name = 'Hermione' GUI input 20

GUI input Variation 4 - miscellaneous options answer = inputdlg(prompt,dlg_title, num_lines,defans,options) options if 'on', can resize box horizontally See Help for other options options! >> name = inputdlg( 'Favorite character', 'Character Information', 1,{'Hermione'} ); >> name = inputdlg( 'Favorite character', 'Character Information', 1,{'Hermione'}, 'on' ); 21

GUI input Try it Make this dialog box and print the user's input as "John Lennon's bride is xxx" where "xxx" is what the user entered. >> name=inputdlg( 'John Lennon''s?', 'Brides' ); >> disp( [ 'John Lennon''s bride is ' name{1} ] ) John Lennon's bride is Yoko Ono 22

Question dialog box button = questdlg( question, title ) Lets user answer by pressing buttons question is a text string or cell array title is text string displayed in box's title bar by default, there are three buttons: 'Yes', 'No', or 'Cancel' button is text string set to one of above three values, or empty if user closed box dialog box is modal GUI input 23

Example >> button = questdlg( 'Save in default folder?',... 'Location of results' ); >> if strcmp( button, 'Yes' ) disp( 'Results stored in default folder' ); elseif strcmp( button, 'No' ) folder = uigetdir; else disp( 'No results stored' ); end GUI input Results stored in default folder Pressing Yes button makes this output 24

Variations GUI input Can specify default button Can specify text and defaults for two buttons Can specify text and defaults for three buttons Can specify miscellaneous options See Help for more information 25

Variation - specify two buttons button = questdlg( question, title, str1, str2, default ) str1 and str2 are a text strings for the two buttons default is str1 or str2 and specifies which button is initially selected Try it Make this dialog box and display the label of the chosen button >> questdlg( 'Which dessert do you like better?',... 'Food survey', 'Pie', 'Ice cream', 'Ice cream' ) ans = Pie GUI input 26

GUI input Some predefined dialog boxes used to get specific types of input Examples: select directory, select file, specify color 27

Standard dialog box for getting file name filename = uigetfile Displays list of files in current folder for user to select If file name valid and file exists, returns file name as character array. Otherwise, displays error message and returns to list If user clicks "Cancel" or closes box, returns 0 (not empty cell!) Dialog box is modal GUI input 28

GUI input Example >> filename = uigetfile; >> if ischar( filename )... disp( ['File: ' filename] );... else disp( 'User canceled' ); end File: uniqueid_assignment2.m 29

GUI input Variation 1 filename = uigetfile( FilterSpec ) filename = uigetfile( FilterSpec,... DialogTitle ) FilterSpec - one or more file specifications, usually with wildcard (*) DialogTitle - title of dialog box See help on uigetfile() for details of FilterSpec 30

GUI input Try it Make a dialog box whose title is "MATLAB m-files" and whose filter specification is "*.m". Call it and display the result >> filename = uigetfile( '*.m',... 'MATLAB m-files' ) filename = assignment2_solution.m 31

Variation 2 [ filename pathname ] = uigetfile() [ filename pathname ] = uigetfile( FilterSpec ) [ filename pathname ] = uigetfile( FilterSpec,... DialogTitle ) filename - name and extension of chosen file pathname - path GUI input 32

GUI input Try it Make a dialog box whose title is "MATLAB m-files" and whose filter specification is "*.m". Maneuver to a different folder, select an m-file, and display the result 33

GUI input Try it >> [ filename pathname ] = uigetfile(... '*.m', 'MATLAB m-files' ) filename = cell_char_compare.m pathname = C:\Greg\CSA 441\2009\ 34

GUI input There are a few pre-defined dialog boxes to get special kinds of input. One example is selecting a color. Use uisetcolor() to do this Try it >> plot(1:10) 35

GUI input Try it >> c = uisetcolor; %pick obnoxious color >> 36

GUI input Try it >> axes( 'color', c ) 37

GUI Input Questions? 38

GUI output Message dialog box msgbox( message ) Displays text to user message is a text string, text matrix or string array Text is automatically wrapped to fit in box User presses "Okay" button to close box Program does not stop executing while waiting for user to close box Dialog box is non-modal (code keeps on running) Use uiwait() to pause code 39

GUI output Try it Call msgbox to display "Passed!", type some other MATLAB commands, then close the message box >> msgbox( 'Passed!' ) >> pwd ans = c:\greg\csa 441\2010\lectures >> date ans = 09-Jul-2010 >> 40

uiwait() makes program stop until message box is closed. Two ways to use: >> h = uiwait( msgbox('hello World')); >> uiwait( h ); or >> uiwait( msgbox('hello World')); Try it Call msgbox within uiwait() and notice that don't get prompt in command window >> uiwait( msgbox( 'Passed!' ) ) >> GUI output Doesn't appear until message box closed 41

GUI output Example keeplooping = true; while keeplooping end answer=inputdlg( 'Enter two characters'); if length( answer{1} ) ~= 2 h = errordlg( 'Enter only two characters' ); uiwait( h ); else end keeplooping = false; 42

GUI output Variation 1 msgbox( message, title ) title is title of message box Try it Display this message box and then close it >> msgbox( 'You passed', 'RESULT' ) 43

Variation 2 msgbox( message, title, icon ) icon specifies an icon to display 'error' 'help' 'warn' GUI output 'custom' (specify your own) 'none' (no icon. This is the default) 44

GUI output Variation 2 Try it Display this message box and then close it >> msgbox( 'You failed the written part of the exam',... 'RESULT', 'warn' ) 45

Some predefined dialog boxes for output are errordlg - Display errors printpreview - Show current figure as it will print waitbar - Open or update a wait bar (progress bar) warndlg - Display warning All are non-modal GUI output 46

GUI Input and Output Questions? 47

The End 48