SlideShare uma empresa Scribd logo
1 de 10
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?

Mais conteúdo relacionado

Mais procurados

Java exception handling
Java exception handlingJava exception handling
Java exception handling
BHUVIJAYAVELU
 

Mais procurados (20)

Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
 
KeyLoggers - beating the shit out of keyboard since quite a long time
KeyLoggers - beating the shit out of keyboard since quite a long timeKeyLoggers - beating the shit out of keyboard since quite a long time
KeyLoggers - beating the shit out of keyboard since quite a long time
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
SRS of Phishing Website Detection using machine learing
SRS of Phishing Website Detection using machine learingSRS of Phishing Website Detection using machine learing
SRS of Phishing Website Detection using machine learing
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
 
PYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.ppt
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler design
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Python – Object Oriented Programming
Python – Object Oriented Programming Python – Object Oriented Programming
Python – Object Oriented Programming
 
Composition in OOP
Composition in OOPComposition in OOP
Composition in OOP
 
Flappy bird game in c#
Flappy bird game in c#Flappy bird game in c#
Flappy bird game in c#
 
Lex & yacc
Lex & yaccLex & yacc
Lex & yacc
 
Regular Expressions in Java
Regular Expressions in JavaRegular Expressions in Java
Regular Expressions in Java
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
CLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONCLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHON
 
Threat hunting and achieving security maturity
Threat hunting and achieving security maturityThreat hunting and achieving security maturity
Threat hunting and achieving security maturity
 
Java Datatypes
Java DatatypesJava Datatypes
Java Datatypes
 
Map, Filter and Reduce In Python
Map, Filter and Reduce In PythonMap, Filter and Reduce In Python
Map, Filter and Reduce In Python
 

Semelhante a Introduction to GUIs with guizero

3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivity
allenbailey
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
sumitjoshi01
 
Gui builder
Gui builderGui builder
Gui builder
learnt
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
Ahsanul Karim
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
Ahsanul Karim
 

Semelhante a Introduction to GUIs with guizero (20)

Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
 
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 swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
 
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)
 
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
 

Mais de 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
 

Último

➥🔝 7737669865 🔝▻ bharuch Call-girls in Women Seeking Men 🔝bharuch🔝 Escorts...
➥🔝 7737669865 🔝▻ bharuch Call-girls in Women Seeking Men  🔝bharuch🔝   Escorts...➥🔝 7737669865 🔝▻ bharuch Call-girls in Women Seeking Men  🔝bharuch🔝   Escorts...
➥🔝 7737669865 🔝▻ bharuch Call-girls in Women Seeking Men 🔝bharuch🔝 Escorts...
amitlee9823
 
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
Just Call Vip call girls fazilka Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls fazilka Escorts ☎️9352988975 Two shot with one girl ...Just Call Vip call girls fazilka Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls fazilka Escorts ☎️9352988975 Two shot with one girl ...
gajnagarg
 
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
gynedubai
 
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
amitlee9823
 
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
amitlee9823
 
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
amitlee9823
 
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...
amitlee9823
 
Cara Gugurkan Kandungan Awal Kehamilan 1 bulan (087776558899)
Cara Gugurkan Kandungan Awal Kehamilan 1 bulan (087776558899)Cara Gugurkan Kandungan Awal Kehamilan 1 bulan (087776558899)
Cara Gugurkan Kandungan Awal Kehamilan 1 bulan (087776558899)
Cara Menggugurkan Kandungan 087776558899
 
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
gajnagarg
 
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
amitlee9823
 
Call Girls Bidadi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Bidadi Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Bidadi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Bidadi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 

Último (20)

➥🔝 7737669865 🔝▻ bharuch Call-girls in Women Seeking Men 🔝bharuch🔝 Escorts...
➥🔝 7737669865 🔝▻ bharuch Call-girls in Women Seeking Men  🔝bharuch🔝   Escorts...➥🔝 7737669865 🔝▻ bharuch Call-girls in Women Seeking Men  🔝bharuch🔝   Escorts...
➥🔝 7737669865 🔝▻ bharuch Call-girls in Women Seeking Men 🔝bharuch🔝 Escorts...
 
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 🥵 Book Your One night Stand
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...
 
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Btm Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Just Call Vip call girls fazilka Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls fazilka Escorts ☎️9352988975 Two shot with one girl ...Just Call Vip call girls fazilka Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls fazilka Escorts ☎️9352988975 Two shot with one girl ...
 
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
 
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
 
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jayanagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
 
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...
 
Personal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando NegronPersonal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando Negron
 
Cara Gugurkan Kandungan Awal Kehamilan 1 bulan (087776558899)
Cara Gugurkan Kandungan Awal Kehamilan 1 bulan (087776558899)Cara Gugurkan Kandungan Awal Kehamilan 1 bulan (087776558899)
Cara Gugurkan Kandungan Awal Kehamilan 1 bulan (087776558899)
 
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
 
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdfDMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
 
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
 
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Bommanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
 
Guide to a Winning Interview May 2024 for MCWN
Guide to a Winning Interview May 2024 for MCWNGuide to a Winning Interview May 2024 for MCWN
Guide to a Winning Interview May 2024 for MCWN
 
Call Girls Bidadi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Bidadi Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Bidadi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Bidadi Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 

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?