Computer Science 111 Fundamentals of Programming I User Interfaces Introduction to GUI programming.

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

Computer Science 112 Fundamentals of Programming II User Interfaces
An Introduction to Visual Basic Terms & Concepts.
Chapter 8 Improving the User Interface
Chapter 2 First Java Programs
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 7 Improving the User Interface
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
Chapter 4 Objects and Graphics
An Introduction to Visual Basic
11.10 Human Computer Interface www. ICT-Teacher.com.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Guide to Programming with Python Chapter Ten GUI Development: The Mad Lib Program.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
Computer Science 111 Fundamentals of Programming I Basic Program Elements.
Chapter 11 An Introduction to Visual Basic 2008 Why Windows and Why Visual Basic How You Develop a Visual Basic Application The Different Versions of Visual.
Computer Science 112 Fundamentals of Programming II Graphics Programming.
Computer Science 111 Fundamentals of Programming I Model/View/Controller and Data model design.
PC204 Lecture 9 Conrad Huang Genentech Hall, N453A x
CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Computer Science 112 Fundamentals of Programming II Command Buttons and Responding to Events.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 20 Graphical User Interface (GUI)
Python Programming Graphical User Interfaces Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Computing Science 1P Lecture 17: Friday 23 rd February Simon Gay Department of Computing Science University of Glasgow 2006/07.
Graphical User Interface You will be used to using programs that have a graphical user interface (GUI). So far you have been writing programs that have.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
Graphics Programming with Python. Many choices Python offers us several library choices:  Tkinter  WxPython  PyQt  PyGTK  Jython  And others...
Creating visual interfaces in python
Guide to Programming with Python
CMPF124 Personal Productivity With Information Technology Chapter 1 – Part 2 Introduction to Windows Operating Systems Manipulating Windows GUI CMPF 124.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
Computer Science 112 Fundamentals of Programming II Data Fields for I/O and Message Boxes for Error Recovery.
Computer Graphics Lecture 1. Books D. Hearn, M. P. Baker, "Computer Graphics with OpenGL", 3rd Ed., Prentice Hall, 2003, ISBN
Allows the user and the computer to communicate with each other.
Fundamentals of Programming I Overview of Programming
Topics Graphical User Interfaces Using the tkinter Module
Computer Science 111 Fundamentals of Programming I
Chapter Topics 15.1 Graphical User Interfaces
Event loops 16-Jun-18.
Chapter 2 First Java Programs
Fundamentals of Programming I The Model/View/Controller Design Pattern
An Introduction to Visual Basic
Computer Science 112 Fundamentals of Programming II GUIs II:
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Fundamentals of Python: From First Programs Through Data Structures
Tkinter GUIs Computer Science and Software Engineering
Fundamentals of Python: First Programs Second Edition
Introduction to Computing Using Java
Event loops.
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Fundamentals of Programming I Windows, Labels, and Command Buttons
Computer Science 111 Fundamentals of Programming I Text Areas
Computer Science 111 Fundamentals of Programming I User Interfaces
Fundamentals of Programming I The Model/View/Controller Design Pattern
Computer Science 111 Fundamentals of Programming I
Chapter 15: GUI Applications & Event-Driven Programming
Event loops 8-Apr-19.
The University of Texas – Pan American
Event loops.
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

Computer Science 111 Fundamentals of Programming I User Interfaces Introduction to GUI programming

Terminal-Based User Interface (TUI) import math radius = float(input('Enter the radius: ')) area = math.pi * radius ** 2 print('The area is', area) Supports input via the keyboard and output via the monitor In Python, the I/O functions are input and print

Terminal-Based User Interface (TUI) import math radius = float(input('Enter the radius: ')) area = math.pi * radius ** 2 print('The area is', area) Supports input via the keyboard and output via the monitor In Python, the I/O functions are input and print

Problems with a TUI Must enter inputs in a certain order Cannot back up to correct input mistakes or change one’s mind Must re-enter all inputs to change just one I/O restricted to text

Graphical User Interface (GUI) Supports input via the keyboard Can output text and also graphical shapes representing desktop elements, such as windows, command buttons, data fields, and drop-down menus (also called “widgets”) Supports direct manipulation of desktop elements via the mouse or touchscreen

TUI vs GUI Non-programmers (the 99%) do not use a TUI, they use a GUI Only programmers (the 1%) use a TUI (and also a GUI) Most beginning programmers program to a TUI, not a GUI

Programming a GUI Most modern programming languages (like Python and Java) include packages or modules for programming a GUI In Python, this module is called tkinter The model of computation for a GUI program is more complex than that of a TUI program

Models of Computation TUI 1.Obtain user inputs 2.Perform computations 3.Print results GUI 1.Layout and pop up the window 2.Wait for user events 3.Handle a user event 4.Goto step 2

GUI Resources in Python tkinter breezypythongui

What Is breezypythongui ? A module of classes and functions that makes GUI programming with tkinter easy for beginners The module is free and open-source A tutorial and sample programs are available at the breezypythongui Web site

A First GUI Program: Hello World from breezypythongui import EasyFrame Import the abstract window class

A First GUI Program: Hello World from breezypythongui import EasyFrame class HelloWorld(EasyFrame): """Displays a greeting in a window.""" Define a subclass to specialize it for this application

A First GUI Program: Hello World from breezypythongui import EasyFrame class HelloWorld(EasyFrame): """Displays a greeting in a window.""" def __init__(self): """Sets up the window and the label.""" EasyFrame.__init__(self) self.addLabel(text = "Hello world!", row = 0, column = 0) Lay out the window and its widgets

A First GUI Program: Hello World from breezypythongui import EasyFrame class HelloWorld(EasyFrame): """Displays a greeting in a window.""" def __init__(self): """Sets up the window and the label.""" EasyFrame.__init__(self) self.addLabel(text = "Hello world!", row = 0, column = 0) # Instantiates and pops up the window. if __name__ == "__main__": HelloWorld().mainloop() Create and launch the application window

The Structure of Any GUI Program from breezypythongui import EasyFrame class (EasyFrame): def __init__(self): EasyFrame.__init__(self ) # Instantiates and pops up the window. if __name__ == "__main__": ().mainloop()

Lay Out Widgets class CircleWithGUI(EasyFrame): """Computes and displays the area of a circle.""" def __init__(self): """Sets up the window and widgets.""" EasyFrame.__init__(self, title = "Circle Area") # Label and field for the input self.addLabel(text = "Radius", row = 0, column = 0) self.radiusField = self.addFloatField(value = 0.0, row = 0, column = 1) # Label and field for the output self.addLabel(text = "Area", row = 1, column = 0) self.areaField = self.addFloatField(value = 0.0, row = 1, column = 1) # The command button self.addButton(text = "Compute", row = 2, column = 0, columnspan = 2, command = self.computeArea)

Define the Event Handler class CircleWithGUI(EasyFrame): """Computes and displays the area of a circle."""... # The event handling method for the button def computeArea(self): """Inputs the radius, computes the area, and outputs the result.""" radius = self.radiusField.getNumber() area = math.pi * radius ** 2 self.areaField.setNumber(area) #Instantiate and pop up the window. if __name__ == "__main__": CircleWithGUI().mainloop()

For Monday Start Chapter 3