1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 20 Graphical User Interface (GUI)

Slides:



Advertisements
Similar presentations
Computer Science 112 Fundamentals of Programming II User Interfaces
Advertisements

Topics in Python Blackjack & TKinter
Chapter 8 Improving the User Interface
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Excel and VBA Creating an Excel Application
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Text Box controls are used when users are required to type some input (during program execution), or output is displayed on the form (known as the user-
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
Introduction to Visual Basic Chulantha Kulasekere.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
I210 review (for final exam) Fall 2011, IUB. What’s in the Final Exam Multiple Choice (5) Short Answer (5) Program Completion (3) Note: A single-sided.
Computer Science 111 Fundamentals of Programming I User Interfaces Introduction to GUI programming.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Creating a Web Site to Gather Data and Conduct Research.
Peter Andreae Python for Level 3 CS4HS see website: ecs.vuw.ac.nz/Main/PythonForSchools.
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,
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
PYTHON GUI PROGRAMMING
Computer Science 112 Fundamentals of Programming II Command Buttons and Responding to Events.
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.
CNS 1410 Graphical User Interfaces. Obectives Students should understand the difference between a procedural program and an Event Driven Program. Students.
Concurrent Programming and Threads Threads Blocking a User Interface.
How the Session Works Outline Practical on arrival Talk 1 Reflect on practical Clarify concepts Practical exercises at your own pace Talk 2: Further concepts.
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.
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Tkinter Basics. Initial Stuff To get the package: from tkinter import * To make a window, give it a title and operate it: windowVar = Tk() windowVar.title(“your.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
Creating visual interfaces in python
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Guide to Programming with Python
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
CSC 121 Computers and Scientific Thinking Fall Event-Driven Programming.
COMPSA Exam Prep Session by Paul Allison On: April 8th from 1:30-3:00 Location TBA Winter 2016CISC101 - Prof. McLeod1.
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.
Topics Graphical User Interfaces Using the tkinter Module
Graphical User Interfaces (GUIs)
Computer Science 111 Fundamentals of Programming I
Chapter Topics 15.1 Graphical User Interfaces
Event loops 16-Jun-18.
Fundamentals of Python: From First Programs Through Data Structures
Event Driven Programming
This Week: Tkinter for GUI Interfaces Some examples
Tkinter GUIs Computer Science and Software Engineering
Basic Elements of The GUI
Event loops.
DB Implementation: MS Access Forms
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 User Interfaces
Topics Graphical User Interfaces Using the tkinter Module
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.
Tkinter User Input Form
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 20 Graphical User Interface (GUI)

2 Graphical User Interface (GUI) The Graphical User Interface (GUI) allows the user to interact with a program using buttons, text boxes, etc. We will use a library of Python classes, Tkinter, to generate the elements of the GUI. GUI classes: FrameHolds other GUI elements LabelDisplays non-editable text ButtonPerforms an action when the user clicks it. EntryAccepts and displays one line of text. TextAccepts and displays multiple lines of text. CheckbuttonAllows user to select options from a list. RadiobuttonAllows user to select a single option of several

3 Event Driven Programming GUI's use Event Driven Programming. The program executes an event loop. The loop continually checks for the occurrence of an event. If an event occurs, the program executes the event handler. It then returns to the event loop to wait for another event.

4 The root window We must have a window to display the GUI. This is called the root window. Example: from Tkinter import *#Import classes root = Tk( )#create the root window root.title("Simple GUI")#Specify title bar text root.geometry("300x150")#Specify width and height root.mainloop( )#run the event loop

5 Using a Frame and Labels A frame contains all the other GUI elements. It's master (the thing that contains it) is the root window. app = Frame(root)#Create the frame with root as master app.grid( )#Make the frame visible A label is text that cannot be edited by the user. lbl = Label(app, text = "I'm a label")#Create a label in the frame lbl.grid( )#Make it visible

6 Using Buttons Creating a button: bttn1 = Button(app, text = "I do nothing.")#Create a button bttn1.grid( )#Make it visible Specifying a command: def button_print( ):#Event handler print "The button has been clicked!"... bttn2 = Button(app, text = "Click me!")#Create button bttn2["command"] = button_print#Bind function bttn2.grid( )#Show button

7 Adding Text Entry Field Writing to an entry box: def button_print( ): global my_entry#the name of the entry field message = "The button was clicked." my_entry.delete(0, END)#Clear the entry field my_entry.insert(0, message) #insert the message... my_entry = Entry(app, width = 35)#width parameter is optional my_entry.grid( )

8 Getting information from an Entry field Use the get( ) function to retrieve whatever's typed in the text field: def button_print( ): global my_entry msg = my_entry.get( )#Get input from user from entry field if msg == "secret": message = "You guessed the password!" else: message = "Try again." my_entry.delete(0, END) my_entry.insert(0, message)... my_entry = Entry(app, width = 35) my_entry.grid( )

9 Using a Text box A text box is similar to an entry field: def button_print( ): global my_entry global txtBox msg = my_entry.get( )#Get input from user from entry field if msg == "secret": message = "You guessed the password!" else: message = "Try again." txtBox.delete(0.0, END)#Need to specify row and column txtBox.insert(0.0, message)... txtBox = Text(app, width = 35, height = 5, wrap = WORD) txtBox.grid( )