SlideShare a Scribd company logo
Introduction to Graphical
User Interfaces
WITH GUIZERO
Introduction to guizero
 Up to this point we have been creating console based
applications that interact with physical devices.
 However when was the last time you had a console based
application…almost never.
 We will be using the module tkinter to develop graphical
interfaces for our users to interact with during program
execution
 The tkinter module is comprised of numerous classes to
create GUI widgets.
 To simplify this process we will use the guizero module which is
a wrapper class, simplifying the implementation of GUI
components.
 From guizero import <INSERT WHAT YOU NEED>
Creating a Graphical User Interface
 There are 2 main components to a GUI.
 1. The window/container
 2. The widgets
 Labels, buttons, text boxes, radio buttons, images, etc.
Creating a Window
 Let’s begin by creating the application window, which is nothing more than a
container for our widgets.
 You will want to import the App class from guizero
 Code: from guizero import App
myApp = App()
myApp.display()
 However, this window will not do much for us unless we modify some of its
properties and add some content.
All the widgets go here
A Windows Starting Parameters/Properties
 When you create an App
windows you can specify any or
all of the below properties upon
creation or program execution.
 Code: myApp = App(title = “First App Window”, bg = “red”, height = 200, width = 250)
Creating a Text/Label Object
 A text is a widget that only displays information.
 Code: from guizero import App, Text
txtlName = Text(appName, optional parameters,…)
 Options include:
 Ex.
txtPrompt = Text(myApp, text =“ Enter a num:”, bg =“red”)
The Event Loop and Processing Events
 GUI’s are event driven, meaning they run when an interaction from the user occurs.
 To determine when an interaction occurs you have to create a listener for every programmable action
there is. These listeners are looking for actions, called events.
 Button Presses, Pressing Enter, Checking a Box, Selecting a Menu Option, …
 Python makes this a bit easier by using an event loop to listen for any interaction on your App window.
Widgets placed between the below two lines will have event listeners constantly checking if their event
has occurred. (More on this when we discuss widgets you can interact with)
 This is because the line of code myApp.display() starts the event loop. The GUI app will constantly check
whether the user has done anything new, and it will automatically update the display if necessary. The
event loop blocks the code, so code written after the event loop will never execute. So this loop acts
rather like a while True: loop.
Example
from guizero import App, Text
#create the window object
wind = App(title = “Our First App”, width = 200, height = 250)
#add a text label
txtName = Text(wind, text = “Jason Rocks!!!!”, fg = “blue”, font =“Helvetica”, size = 16)
#begin event loop
wind.display()
The Widget Classes
 When creating a widget there are
specific parameters for each to specify.
 Where to place it
 Properties
 Variables to set, etc.
 Many of the properties are similar for each
widget
 There are also functions/methods for each
widget to allow interaction.
Checkpoint
1. What is an event loop?
2. What are the 3 minimum lines of codes to create a GUI App?
3. What are widgets?

More Related Content

Similar to Introduction to GUIs with guizero

GTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon ChooserGTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon Chooser
William Lee
 
Learning Android Part 2/6
Learning Android Part 2/6Learning Android Part 2/6
Learning Android Part 2/6
Girish Bellalcheru
 
3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivityallenbailey
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
veeracynixit
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
veeracynixit
 
06 win forms
06 win forms06 win forms
06 win forms
mrjw
 
Appy builder beginner tutorial
Appy builder beginner tutorialAppy builder beginner tutorial
Appy builder beginner tutorial
HabibulHakam
 
Chapter - 6.pptx
Chapter - 6.pptxChapter - 6.pptx
Chapter - 6.pptx
MikialeTesfamariam
 
Getting Started With Developing For Apple Watch
Getting Started With Developing For Apple WatchGetting Started With Developing For Apple Watch
Getting Started With Developing For Apple Watch
InMobi
 
Synapse india reviews on gui programming in .net
Synapse india reviews on gui programming in .netSynapse india reviews on gui programming in .net
Synapse india reviews on gui programming in .net
saritasingh19866
 
Getting Started with Developing for the Apple Watch
Getting Started with Developing for the Apple WatchGetting Started with Developing for the Apple Watch
Getting Started with Developing for the Apple Watch
Murtza Manzur
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.doc
Palakjaiswal43
 
The java rogramming swing _tutorial for beinners(java programming language)
The java rogramming swing _tutorial for beinners(java programming language)The java rogramming swing _tutorial for beinners(java programming language)
The java rogramming swing _tutorial for beinners(java programming language)
Daroko blog(www.professionalbloggertricks.com)
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorialsumitjoshi01
 
Unit-1.pptx
Unit-1.pptxUnit-1.pptx
Unit-1.pptx
VikasTuwar1
 
Gui builder
Gui builderGui builder
Gui builderlearnt
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesAhsanul Karim
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesAhsanul Karim
 
Take a Ride on the Metro
Take a Ride on the MetroTake a Ride on the Metro

Similar to Introduction to GUIs with guizero (20)

GTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon ChooserGTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon Chooser
 
UIAutomator
UIAutomatorUIAutomator
UIAutomator
 
Learning Android Part 2/6
Learning Android Part 2/6Learning Android Part 2/6
Learning Android Part 2/6
 
3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivity
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
 
06 win forms
06 win forms06 win forms
06 win forms
 
Appy builder beginner tutorial
Appy builder beginner tutorialAppy builder beginner tutorial
Appy builder beginner tutorial
 
Chapter - 6.pptx
Chapter - 6.pptxChapter - 6.pptx
Chapter - 6.pptx
 
Getting Started With Developing For Apple Watch
Getting Started With Developing For Apple WatchGetting Started With Developing For Apple Watch
Getting Started With Developing For Apple Watch
 
Synapse india reviews on gui programming in .net
Synapse india reviews on gui programming in .netSynapse india reviews on gui programming in .net
Synapse india reviews on gui programming in .net
 
Getting Started with Developing for the Apple Watch
Getting Started with Developing for the Apple WatchGetting Started with Developing for the Apple Watch
Getting Started with Developing for the Apple Watch
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.doc
 
The java rogramming swing _tutorial for beinners(java programming language)
The java rogramming swing _tutorial for beinners(java programming language)The java rogramming swing _tutorial for beinners(java programming language)
The java rogramming swing _tutorial for beinners(java programming language)
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
 
Unit-1.pptx
Unit-1.pptxUnit-1.pptx
Unit-1.pptx
 
Gui builder
Gui builderGui builder
Gui builder
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Take a Ride on the Metro
Take a Ride on the MetroTake a Ride on the Metro
Take a Ride on the Metro
 

More from primeteacher32

Software Development Life Cycle
Software Development Life CycleSoftware Development Life Cycle
Software Development Life Cycle
primeteacher32
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
primeteacher32
 
Returning Data
Returning DataReturning Data
Returning Data
primeteacher32
 
Intro to Functions
Intro to FunctionsIntro to Functions
Intro to Functions
primeteacher32
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
primeteacher32
 
Nested Loops
Nested LoopsNested Loops
Nested Loops
primeteacher32
 
Conditional Loops
Conditional LoopsConditional Loops
Conditional Loops
primeteacher32
 
Introduction to Repetition Structures
Introduction to Repetition StructuresIntroduction to Repetition Structures
Introduction to Repetition Structures
primeteacher32
 
Input Validation
Input ValidationInput Validation
Input Validation
primeteacher32
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
primeteacher32
 
Nesting Conditionals
Nesting ConditionalsNesting Conditionals
Nesting Conditionals
primeteacher32
 
Conditionals
ConditionalsConditionals
Conditionals
primeteacher32
 
Intro to Python with GPIO
Intro to Python with GPIOIntro to Python with GPIO
Intro to Python with GPIO
primeteacher32
 
Variables and Statements
Variables and StatementsVariables and Statements
Variables and Statements
primeteacher32
 
Variables and User Input
Variables and User InputVariables and User Input
Variables and User Input
primeteacher32
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
primeteacher32
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
primeteacher32
 
Hardware vs. Software Presentations
Hardware vs. Software PresentationsHardware vs. Software Presentations
Hardware vs. Software Presentations
primeteacher32
 
Block chain security
Block chain securityBlock chain security
Block chain security
primeteacher32
 
Hashes
HashesHashes

More from primeteacher32 (20)

Software Development Life Cycle
Software Development Life CycleSoftware Development Life Cycle
Software Development Life Cycle
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
 
Returning Data
Returning DataReturning Data
Returning Data
 
Intro to Functions
Intro to FunctionsIntro to Functions
Intro to Functions
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
Nested Loops
Nested LoopsNested Loops
Nested Loops
 
Conditional Loops
Conditional LoopsConditional Loops
Conditional Loops
 
Introduction to Repetition Structures
Introduction to Repetition StructuresIntroduction to Repetition Structures
Introduction to Repetition Structures
 
Input Validation
Input ValidationInput Validation
Input Validation
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
 
Nesting Conditionals
Nesting ConditionalsNesting Conditionals
Nesting Conditionals
 
Conditionals
ConditionalsConditionals
Conditionals
 
Intro to Python with GPIO
Intro to Python with GPIOIntro to Python with GPIO
Intro to Python with GPIO
 
Variables and Statements
Variables and StatementsVariables and Statements
Variables and Statements
 
Variables and User Input
Variables and User InputVariables and User Input
Variables and User Input
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Hardware vs. Software Presentations
Hardware vs. Software PresentationsHardware vs. Software Presentations
Hardware vs. Software Presentations
 
Block chain security
Block chain securityBlock chain security
Block chain security
 
Hashes
HashesHashes
Hashes
 

Recently uploaded

欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
foismail170
 
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
atwvhyhm
 
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR GeneralistHeidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
HeidiLivengood
 
Personal Brand Exploration Comedy Jxnelle.
Personal Brand Exploration Comedy Jxnelle.Personal Brand Exploration Comedy Jxnelle.
Personal Brand Exploration Comedy Jxnelle.
alexthomas971
 
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
foismail170
 
Luke Royak's Personal Brand Exploration!
Luke Royak's Personal Brand Exploration!Luke Royak's Personal Brand Exploration!
Luke Royak's Personal Brand Exploration!
LukeRoyak
 
How to create an effective K-POC tutorial
How to create an effective K-POC tutorialHow to create an effective K-POC tutorial
How to create an effective K-POC tutorial
vencislavkaaa
 
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdfRECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
AlessandroMartins454470
 
Midterm Contract Law and Adminstration.pptx
Midterm Contract Law and Adminstration.pptxMidterm Contract Law and Adminstration.pptx
Midterm Contract Law and Adminstration.pptx
Sheldon Byron
 
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
foismail170
 
The Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdfThe Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdf
ssuser3e63fc
 
How Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
How Mentoring Elevates Your PM Career | PMI Silver Spring ChapterHow Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
How Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
Hector Del Castillo, CPM, CPMM
 
Full Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptxFull Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptx
mmorales2173
 
135. Reviewer Certificate in Journal of Engineering
135. Reviewer Certificate in Journal of Engineering135. Reviewer Certificate in Journal of Engineering
135. Reviewer Certificate in Journal of Engineering
Manu Mitra
 
Brand Identity For A Sportscaster Project and Portfolio I
Brand Identity For A Sportscaster Project and Portfolio IBrand Identity For A Sportscaster Project and Portfolio I
Brand Identity For A Sportscaster Project and Portfolio I
thomasaolson2000
 
han han widi kembar tapi beda han han dan widi kembar tapi sama
han han widi kembar tapi beda han han dan widi kembar tapi samahan han widi kembar tapi beda han han dan widi kembar tapi sama
han han widi kembar tapi beda han han dan widi kembar tapi sama
IrlanMalik
 
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaaInteractive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
23211a7274
 
DIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptxDIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptx
FarzanaRbcomcs
 
Exploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical CommunicatorsExploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical Communicators
Ben Woelk, CISSP, CPTC
 
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
yuhofha
 

Recently uploaded (20)

欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
 
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
 
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR GeneralistHeidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
 
Personal Brand Exploration Comedy Jxnelle.
Personal Brand Exploration Comedy Jxnelle.Personal Brand Exploration Comedy Jxnelle.
Personal Brand Exploration Comedy Jxnelle.
 
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
 
Luke Royak's Personal Brand Exploration!
Luke Royak's Personal Brand Exploration!Luke Royak's Personal Brand Exploration!
Luke Royak's Personal Brand Exploration!
 
How to create an effective K-POC tutorial
How to create an effective K-POC tutorialHow to create an effective K-POC tutorial
How to create an effective K-POC tutorial
 
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdfRECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
 
Midterm Contract Law and Adminstration.pptx
Midterm Contract Law and Adminstration.pptxMidterm Contract Law and Adminstration.pptx
Midterm Contract Law and Adminstration.pptx
 
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
 
The Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdfThe Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdf
 
How Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
How Mentoring Elevates Your PM Career | PMI Silver Spring ChapterHow Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
How Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
 
Full Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptxFull Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptx
 
135. Reviewer Certificate in Journal of Engineering
135. Reviewer Certificate in Journal of Engineering135. Reviewer Certificate in Journal of Engineering
135. Reviewer Certificate in Journal of Engineering
 
Brand Identity For A Sportscaster Project and Portfolio I
Brand Identity For A Sportscaster Project and Portfolio IBrand Identity For A Sportscaster Project and Portfolio I
Brand Identity For A Sportscaster Project and Portfolio I
 
han han widi kembar tapi beda han han dan widi kembar tapi sama
han han widi kembar tapi beda han han dan widi kembar tapi samahan han widi kembar tapi beda han han dan widi kembar tapi sama
han han widi kembar tapi beda han han dan widi kembar tapi sama
 
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaaInteractive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
 
DIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptxDIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptx
 
Exploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical CommunicatorsExploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical Communicators
 
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
 

Introduction to GUIs with guizero

  • 1. Introduction to Graphical User Interfaces WITH GUIZERO
  • 2. Introduction to guizero  Up to this point we have been creating console based applications that interact with physical devices.  However when was the last time you had a console based application…almost never.  We will be using the module tkinter to develop graphical interfaces for our users to interact with during program execution  The tkinter module is comprised of numerous classes to create GUI widgets.  To simplify this process we will use the guizero module which is a wrapper class, simplifying the implementation of GUI components.  From guizero import <INSERT WHAT YOU NEED>
  • 3. Creating a Graphical User Interface  There are 2 main components to a GUI.  1. The window/container  2. The widgets  Labels, buttons, text boxes, radio buttons, images, etc.
  • 4. Creating a Window  Let’s begin by creating the application window, which is nothing more than a container for our widgets.  You will want to import the App class from guizero  Code: from guizero import App myApp = App() myApp.display()  However, this window will not do much for us unless we modify some of its properties and add some content. All the widgets go here
  • 5. A Windows Starting Parameters/Properties  When you create an App windows you can specify any or all of the below properties upon creation or program execution.  Code: myApp = App(title = “First App Window”, bg = “red”, height = 200, width = 250)
  • 6. Creating a Text/Label Object  A text is a widget that only displays information.  Code: from guizero import App, Text txtlName = Text(appName, optional parameters,…)  Options include:  Ex. txtPrompt = Text(myApp, text =“ Enter a num:”, bg =“red”)
  • 7. The Event Loop and Processing Events  GUI’s are event driven, meaning they run when an interaction from the user occurs.  To determine when an interaction occurs you have to create a listener for every programmable action there is. These listeners are looking for actions, called events.  Button Presses, Pressing Enter, Checking a Box, Selecting a Menu Option, …  Python makes this a bit easier by using an event loop to listen for any interaction on your App window. Widgets placed between the below two lines will have event listeners constantly checking if their event has occurred. (More on this when we discuss widgets you can interact with)  This is because the line of code myApp.display() starts the event loop. The GUI app will constantly check whether the user has done anything new, and it will automatically update the display if necessary. The event loop blocks the code, so code written after the event loop will never execute. So this loop acts rather like a while True: loop.
  • 8. Example from guizero import App, Text #create the window object wind = App(title = “Our First App”, width = 200, height = 250) #add a text label txtName = Text(wind, text = “Jason Rocks!!!!”, fg = “blue”, font =“Helvetica”, size = 16) #begin event loop wind.display()
  • 9. The Widget Classes  When creating a widget there are specific parameters for each to specify.  Where to place it  Properties  Variables to set, etc.  Many of the properties are similar for each widget  There are also functions/methods for each widget to allow interaction.
  • 10. Checkpoint 1. What is an event loop? 2. What are the 3 minimum lines of codes to create a GUI App? 3. What are widgets?