SlideShare a Scribd company logo
Python Certification Training https://www.edureka.co/python
Agenda
Tkinter
Python Certification Training https://www.edureka.co/python
Agenda
Tkinter
Python Certification Training https://www.edureka.co/python
Agenda
Introduction 01
Introduction
to Flask
Getting Started 02
Concepts 03
Practical Approach 04
Installing and working
with Flask
Looking at code to
understand theory
Overview of all the
concepts in Flask
Python Certification Training https://www.edureka.co/python
What Is A Graphical User Interface?
Tkinter
Python Certification Training https://www.edureka.co/python
What Is A GUI?
GUI is a desktop app which helps you to interact with computersWhat is GUI?
GUI
Text Editors Games Apps
I’ll learn Tkinter!
Python Certification Training https://www.edureka.co/python
Why We Need GUI?
The graphical user interface, is a type of user interface that allows users to interact
with electronic devices through graphical icons and visual indicators
Graphical User InterfaceCommand Line
Python Certification Training https://www.edureka.co/python
Python Libraries For GUI
Tkinter
Python Certification Training https://www.edureka.co/python
Why We Need GUI?
Life without Tkinter! Using Tkinter!
Python Certification Training https://www.edureka.co/python
What Is Tkinter?
Tkinter
Python Certification Training https://www.edureka.co/python
Introduction to Flask
Tkinter in Python GUI Programming is standard Python GUI library
It gives us an object-oriented interface to the Tk GUI toolkit
Python Certification Training https://www.edureka.co/python
Fundamentals Of Tkinter
Tkinter
Python Certification Training https://www.edureka.co/python
First Window Using Tkinter
Import the Tkinter module Create the GUI application main window
Add WidgetsEnter the main event loop
import tkinter
window = tkinter.Tk()
# to rename the title of the window
window.title("GUI")
# pack is used to show the object in
the window
label = tkinter.Label(window, text =
"Hello World!").pack()
window.mainloop()
Python Certification Training https://www.edureka.co/python
Tkinter Widgets
Tkinter
Python Certification Training https://www.edureka.co/python
Adding Widgets To Our Application
A widget is an element of a graphical user interface (GUI) that displays information or provides
a specific way for a user to interact with the operating system or an application
Label Button Entry
ComboBox CheckButton Radio
ScrolledText SpinBox Menu Bar
Notebook
Python Certification Training https://www.edureka.co/python
Label Widget
Label You can set the label font so you can make it bigger and maybe bold
l1 = Label (window, text="edureka!“ font=("Arial Bold", 50))
l1.grid (column=0, row=0)
Changing the font style
and size
Output:
Example:
Python Certification Training https://www.edureka.co/python
Label Widget
Label We can set the default window size using geometry function
Example:
l1 = Label (window, text="edureka!“ font=("Arial Bold", 50))
window.geometry('350x200')
l1.grid (column=0, row=0)
The above line sets the window width to
350 pixels and the height to 200 pixels
Output:
Python Certification Training https://www.edureka.co/python
Button Widget
Button
Let’s start by adding the button to the window, the button is
created and added to the window the same as the label
Example:
Output:
bt = Button (window, text="Enter")
bt.grid (column=1, row=0)
Using grid function to
set the button position
Python Certification Training https://www.edureka.co/python
Button Widget
Button
• You can change foreground for a button or any other widget using fg property.
• Also, you can change the background color for any widget using bg property.
Example:
Output:
bt = Button (window, text="Enter", bg="orange", fg="red")
bt.grid (column=1, row=0)
Changing the background
and foreground color
Python Certification Training https://www.edureka.co/python
Button Widget
Button
• Let’s add button click event
• First, we will write the function that we need to execute when the button is clicked
Example:
def clicked():
l1.configure (text="Button was clicked !!")
bt = Button (window, text=“Enter”, command=clicked)
Function that will execute
the button click event
Wiring the button with the
function
Python Certification Training https://www.edureka.co/python
Entry Widget
Entry
In the previous Python GUI examples, we saw how to add simple widgets.
Now let’s try getting the user input using Tkinter Entry class (Tkinter textbox)
txt = Entry(window,width=10)
txt.grid(column=1, row=0)
def clicked():
res = "Welcome to " + txt.get()
l1.configure(text= res)
bt = Button (window, text=“Enter”, command=clicked)
Creating a textbox using
Tkinter Entry class
Once the button is clicked show
“Welcome to” concatenated with the
entered text
Example:
Python Certification Training https://www.edureka.co/python
Entry Widget
Entry
Python Certification Training https://www.edureka.co/python
Combobox Widget
Combobox Combobox Widgets are very easy to use and are widely used as well!
Example:
from tkinter.ttk import *
combo = Combobox(window)
combo['values']= (1, 2, 3, 4, 5, "Text")
combo.current(3)
combo.grid(column=0, row=0)
Adding the combobox items
using the tuple
Setting the selected item
Python Certification Training https://www.edureka.co/python
Combobox Widget
Python Certification Training https://www.edureka.co/python
Checkbutton Widget
Checkbutton To create a checkbutton widget, you can use Checkbutton class
Example:
chk_state = BooleanVar()
chk_state.set (True)
chk = Checkbutton(window, text=‘Select', var=chk_state)
chk.grid(column=0, row=0)
Creating a variable of type BooleanVar which is not a
standard Python variable, it’s a Tkinter variable
Passing the chk_state to the Checkbutton
class to set the check state
Python Certification Training https://www.edureka.co/python
Checkbutton Widget
Checkbutton
Python Certification Training https://www.edureka.co/python
Radio Button Widget
Radio Button To add radio buttons, simply you can use RadioButton class
Example:
rad1 = Radiobutton(window, text=Python', value=1)
rad2 = Radiobutton(window, text=Java', value=2)
rad3 = Radiobutton(window, text=Scala', value=3)
rad1.grid(column=0, row=0)
rad2.grid(column=1, row=0)
rad3.grid(column=2, row=0)
You should set the value for every radio button
with a different value, otherwise, they won’t work
Python Certification Training https://www.edureka.co/python
Radio Button Widget
Radio Button
Python Certification Training https://www.edureka.co/python
ScrolledText Widget
ScrolledText To add a ScrolledText widget, you can use the ScrolledText class
from tkinter import scrolledtext
txt = scrolledtext.ScrolledText(window, width=40,height=10)
Here we specify the width and the height of the ScrolledText widget,
otherwise, it will fill the entire window
To set scrolledtext content, you can use the insert method - txt.insert(INSERT,'You text goes here')
Example:
Python Certification Training https://www.edureka.co/python
MessageBox Widget
MessageBox To show a message box using Tkinter, you can use messagebox library
Example:
from tkinter import messagebox
messagebox.showinfo('Message title’, 'Message content')
def clicked():
messagebox.showinfo('Message title', 'Message content')
btn = Button(window,text=‘ENTER', command=clicked)
Example:
Shows a message box when the user clicks a button
Python Certification Training https://www.edureka.co/python
MessageBox Widget
MessageBox
Python Certification Training https://www.edureka.co/python
SpinBox Widget
SpinBox To create a Spinbox widget, you can use the Spinbox class
spin = Spinbox(window, from_=0, to=100, width=5)
Output:Example:
Python Certification Training https://www.edureka.co/python
Geometry Management
Tkinter
Python Certification Training https://www.edureka.co/python
Geometry Management
All tkinter widgets will have geometric measurements
pack() grid() place()
It organizes the
widgets in the block,
which mean it
occupies the entire
available width
It organizes the
widgets in table-like
structure
It's used to place the
widgets at a specific
position you want.
Geometry Manager Classes
Python Certification Training https://www.edureka.co/python
Organizing Layout & Widgets
Tkinter
Python Certification Training https://www.edureka.co/python
Organizing Layout And Widgets
We use Frame class to arrange layout in a window
Frame is used to create the divisions in the window. You can align the
frames as you like with side parameter of pack() method.
Button is used to create a button in the window. It takes several parameters like
text(Value of the Button), fg(Color of the text), bg(Background color)
Frame
Button
Let’s see some code
Python Certification Training https://www.edureka.co/python
Organizing Layout And Widgets
Sample Login Box
Grid is another way to organize the widgets. It
uses the Matrix row column concepts.
Grid
Let’s see more code
Python Certification Training https://www.edureka.co/python
Binding Functions
Tkinter
Python Certification Training https://www.edureka.co/python
Binding Functions
Calling functions whenever an event occurs
refers to a binding function.
Binding
I like code!
import tkinter
window = tkinter.Tk()
window.title("GUI")
# creating a function called say_hi()
def say_hi():
tkinter.Label(window, text = "Hi").pack()
tkinter.Button(window, text = "Click Me!", command = say_hi).pack()
window.mainloop()
Python Certification Training https://www.edureka.co/python
Event Handling
Tkinter
Python Certification Training https://www.edureka.co/python
Event Handling
mousemove, mouseover, clicking, scrolling are some eventsEvents
<Button-1> <Button-2> <Button-3>
Left Click Middle Click Right Click
Mouse Buttons
Python Certification Training https://www.edureka.co/python
Images & Icons
Tkinter
Python Certification Training https://www.edureka.co/python
Images & Icons
Images can be added using the PhotoImage methodAdd Images
We love Edureka <3
Python Certification Training https://www.edureka.co/python
Use Case
Tkinter
Python Certification Training https://www.edureka.co/python
Let us design our own basic calculator using tkinter
Use Case – Simple Calculator
Python Certification Training https://www.edureka.co/python
Conclusion
Tkinter
Python Certification Training https://www.edureka.co/python
Conclusion
I learnt Tkinter, yay!
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Python Training | Edureka

More Related Content

What's hot (20)

Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
Mohammed Sikander
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
ismailmrribi
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
TMARAGATHAM
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
Laxman Puri
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
Kamal Acharya
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
Rajendran
 
Python Modules
Python ModulesPython Modules
Python Modules
Nitin Reddy Katkam
 
Operators in python
Operators in pythonOperators in python
Operators in python
eShikshak
 
Python
PythonPython
Python
Aashish Jain
 
Python Exception Handling
Python Exception HandlingPython Exception Handling
Python Exception Handling
Megha V
 
Python introduction
Python introductionPython introduction
Python introduction
Jignesh Kariya
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
Nowell Strite
 
Operators in python
Operators in pythonOperators in python
Operators in python
Prabhakaran V M
 
Python PPT
Python PPTPython PPT
Python PPT
Edureka!
 
Error and exception in python
Error and exception in pythonError and exception in python
Error and exception in python
junnubabu
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
Shivam Gupta
 
Threads in python
Threads in pythonThreads in python
Threads in python
baabtra.com - No. 1 supplier of quality freshers
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
Mohammed Sikander
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
ismailmrribi
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
TMARAGATHAM
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
Laxman Puri
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
Kamal Acharya
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
Rajendran
 
Operators in python
Operators in pythonOperators in python
Operators in python
eShikshak
 
Python Exception Handling
Python Exception HandlingPython Exception Handling
Python Exception Handling
Megha V
 
Python introduction
Python introductionPython introduction
Python introduction
Jignesh Kariya
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
Nowell Strite
 
Operators in python
Operators in pythonOperators in python
Operators in python
Prabhakaran V M
 
Python PPT
Python PPTPython PPT
Python PPT
Edureka!
 
Error and exception in python
Error and exception in pythonError and exception in python
Error and exception in python
junnubabu
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
Shivam Gupta
 

Similar to Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Python Training | Edureka (20)

GUI In Python.pdf By : Sangeeta M Chauhan , Gwalior
GUI In Python.pdf By : Sangeeta M Chauhan , GwaliorGUI In Python.pdf By : Sangeeta M Chauhan , Gwalior
GUI In Python.pdf By : Sangeeta M Chauhan , Gwalior
jonathanlimberestrad
 
Tkinter_GUI_Programming_in_Pythovvn.pptx
Tkinter_GUI_Programming_in_Pythovvn.pptxTkinter_GUI_Programming_in_Pythovvn.pptx
Tkinter_GUI_Programming_in_Pythovvn.pptx
MohamedHany892810
 
Tkinter_GUI_Programming_in_ Python.pdf
Tkinter_GUI_Programming_in_    Python.pdfTkinter_GUI_Programming_in_    Python.pdf
Tkinter_GUI_Programming_in_ Python.pdf
AnmolMogalai
 
Tkinter_GUI_Programming_in_Python.pdf
Tkinter_GUI_Programming_in_Python.pdfTkinter_GUI_Programming_in_Python.pdf
Tkinter_GUI_Programming_in_Python.pdf
ArielManzano3
 
ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)
oudesign
 
tkinterpptxguipythonImport it is named ‘tkinter
tkinterpptxguipythonImport  it is named ‘tkintertkinterpptxguipythonImport  it is named ‘tkinter
tkinterpptxguipythonImport it is named ‘tkinter
ssuser6bbf39
 
Chapter - 6.pptx
Chapter - 6.pptxChapter - 6.pptx
Chapter - 6.pptx
MikialeTesfamariam
 
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAPYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
Maulik Borsaniya
 
Gui programming
Gui programmingGui programming
Gui programming
manikanta361
 
Python Programming
Python ProgrammingPython Programming
Python Programming
KennedyRodriguez4
 
Py-Slides-10.ppt Python Programming AIML
Py-Slides-10.ppt Python Programming AIMLPy-Slides-10.ppt Python Programming AIML
Py-Slides-10.ppt Python Programming AIML
webinartrainer
 
GUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptxGUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptx
dvarshitha04
 
A Complete seminar on GUI Development in python
A Complete seminar on GUI Development in pythonA Complete seminar on GUI Development in python
A Complete seminar on GUI Development in python
18547Mymoon
 
Python.pdf textbooks content Artificical
Python.pdf textbooks content ArtificicalPython.pdf textbooks content Artificical
Python.pdf textbooks content Artificical
webinartrainer
 
Python is a high-level, general-purpose programming language. Its design phil...
Python is a high-level, general-purpose programming language. Its design phil...Python is a high-level, general-purpose programming language. Its design phil...
Python is a high-level, general-purpose programming language. Its design phil...
bhargavi804095
 
Introduction to Graphics
Introduction to GraphicsIntroduction to Graphics
Introduction to Graphics
primeteacher32
 
lec 9.pptx
lec 9.pptxlec 9.pptx
lec 9.pptx
MaheshSharan
 
d1c70870-58fb-4da8-ae54-28d1c44a7347.pptx
d1c70870-58fb-4da8-ae54-28d1c44a7347.pptxd1c70870-58fb-4da8-ae54-28d1c44a7347.pptx
d1c70870-58fb-4da8-ae54-28d1c44a7347.pptx
pritigaikwad801
 
GUI Programming with TKinter and Tkinter Widgets.pdf
GUI Programming with TKinter and Tkinter Widgets.pdfGUI Programming with TKinter and Tkinter Widgets.pdf
GUI Programming with TKinter and Tkinter Widgets.pdf
sumitt6_25730773
 
PYTHONNANGCAO_1.GUI.Creating the GUI Form and Adding Widgets.pptx
PYTHONNANGCAO_1.GUI.Creating the GUI Form and Adding Widgets.pptxPYTHONNANGCAO_1.GUI.Creating the GUI Form and Adding Widgets.pptx
PYTHONNANGCAO_1.GUI.Creating the GUI Form and Adding Widgets.pptx
TrangNguyenThiHuyen6
 
GUI In Python.pdf By : Sangeeta M Chauhan , Gwalior
GUI In Python.pdf By : Sangeeta M Chauhan , GwaliorGUI In Python.pdf By : Sangeeta M Chauhan , Gwalior
GUI In Python.pdf By : Sangeeta M Chauhan , Gwalior
jonathanlimberestrad
 
Tkinter_GUI_Programming_in_Pythovvn.pptx
Tkinter_GUI_Programming_in_Pythovvn.pptxTkinter_GUI_Programming_in_Pythovvn.pptx
Tkinter_GUI_Programming_in_Pythovvn.pptx
MohamedHany892810
 
Tkinter_GUI_Programming_in_ Python.pdf
Tkinter_GUI_Programming_in_    Python.pdfTkinter_GUI_Programming_in_    Python.pdf
Tkinter_GUI_Programming_in_ Python.pdf
AnmolMogalai
 
Tkinter_GUI_Programming_in_Python.pdf
Tkinter_GUI_Programming_in_Python.pdfTkinter_GUI_Programming_in_Python.pdf
Tkinter_GUI_Programming_in_Python.pdf
ArielManzano3
 
ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)
oudesign
 
tkinterpptxguipythonImport it is named ‘tkinter
tkinterpptxguipythonImport  it is named ‘tkintertkinterpptxguipythonImport  it is named ‘tkinter
tkinterpptxguipythonImport it is named ‘tkinter
ssuser6bbf39
 
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAPYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
Maulik Borsaniya
 
Gui programming
Gui programmingGui programming
Gui programming
manikanta361
 
Py-Slides-10.ppt Python Programming AIML
Py-Slides-10.ppt Python Programming AIMLPy-Slides-10.ppt Python Programming AIML
Py-Slides-10.ppt Python Programming AIML
webinartrainer
 
GUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptxGUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptx
dvarshitha04
 
A Complete seminar on GUI Development in python
A Complete seminar on GUI Development in pythonA Complete seminar on GUI Development in python
A Complete seminar on GUI Development in python
18547Mymoon
 
Python.pdf textbooks content Artificical
Python.pdf textbooks content ArtificicalPython.pdf textbooks content Artificical
Python.pdf textbooks content Artificical
webinartrainer
 
Python is a high-level, general-purpose programming language. Its design phil...
Python is a high-level, general-purpose programming language. Its design phil...Python is a high-level, general-purpose programming language. Its design phil...
Python is a high-level, general-purpose programming language. Its design phil...
bhargavi804095
 
Introduction to Graphics
Introduction to GraphicsIntroduction to Graphics
Introduction to Graphics
primeteacher32
 
d1c70870-58fb-4da8-ae54-28d1c44a7347.pptx
d1c70870-58fb-4da8-ae54-28d1c44a7347.pptxd1c70870-58fb-4da8-ae54-28d1c44a7347.pptx
d1c70870-58fb-4da8-ae54-28d1c44a7347.pptx
pritigaikwad801
 
GUI Programming with TKinter and Tkinter Widgets.pdf
GUI Programming with TKinter and Tkinter Widgets.pdfGUI Programming with TKinter and Tkinter Widgets.pdf
GUI Programming with TKinter and Tkinter Widgets.pdf
sumitt6_25730773
 
PYTHONNANGCAO_1.GUI.Creating the GUI Form and Adding Widgets.pptx
PYTHONNANGCAO_1.GUI.Creating the GUI Form and Adding Widgets.pptxPYTHONNANGCAO_1.GUI.Creating the GUI Form and Adding Widgets.pptx
PYTHONNANGCAO_1.GUI.Creating the GUI Form and Adding Widgets.pptx
TrangNguyenThiHuyen6
 
Ad

More from Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
 
Ad

Recently uploaded (20)

End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 ADr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr. Jimmy Schwarzkopf
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
Introducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRCIntroducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRC
Adtran
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptxECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
Jasper Oosterveld
 
Co-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using ProvenanceCo-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using Provenance
Paul Groth
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
James Anderson
 
Agentic AI - The New Era of Intelligence
Agentic AI - The New Era of IntelligenceAgentic AI - The New Era of Intelligence
Agentic AI - The New Era of Intelligence
Muzammil Shah
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Fortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in CybersecurityFortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in Cybersecurity
VICTOR MAESTRE RAMIREZ
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...
pranavbodhak
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 ADr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr. Jimmy Schwarzkopf
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
Introducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRCIntroducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRC
Adtran
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptxECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
Jasper Oosterveld
 
Co-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using ProvenanceCo-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using Provenance
Paul Groth
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
James Anderson
 
Agentic AI - The New Era of Intelligence
Agentic AI - The New Era of IntelligenceAgentic AI - The New Era of Intelligence
Agentic AI - The New Era of Intelligence
Muzammil Shah
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Fortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in CybersecurityFortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in Cybersecurity
VICTOR MAESTRE RAMIREZ
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...
pranavbodhak
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 

Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Python Training | Edureka

  • 1. Python Certification Training https://www.edureka.co/python Agenda Tkinter
  • 2. Python Certification Training https://www.edureka.co/python Agenda Tkinter
  • 3. Python Certification Training https://www.edureka.co/python Agenda Introduction 01 Introduction to Flask Getting Started 02 Concepts 03 Practical Approach 04 Installing and working with Flask Looking at code to understand theory Overview of all the concepts in Flask
  • 4. Python Certification Training https://www.edureka.co/python What Is A Graphical User Interface? Tkinter
  • 5. Python Certification Training https://www.edureka.co/python What Is A GUI? GUI is a desktop app which helps you to interact with computersWhat is GUI? GUI Text Editors Games Apps I’ll learn Tkinter!
  • 6. Python Certification Training https://www.edureka.co/python Why We Need GUI? The graphical user interface, is a type of user interface that allows users to interact with electronic devices through graphical icons and visual indicators Graphical User InterfaceCommand Line
  • 7. Python Certification Training https://www.edureka.co/python Python Libraries For GUI Tkinter
  • 8. Python Certification Training https://www.edureka.co/python Why We Need GUI? Life without Tkinter! Using Tkinter!
  • 9. Python Certification Training https://www.edureka.co/python What Is Tkinter? Tkinter
  • 10. Python Certification Training https://www.edureka.co/python Introduction to Flask Tkinter in Python GUI Programming is standard Python GUI library It gives us an object-oriented interface to the Tk GUI toolkit
  • 11. Python Certification Training https://www.edureka.co/python Fundamentals Of Tkinter Tkinter
  • 12. Python Certification Training https://www.edureka.co/python First Window Using Tkinter Import the Tkinter module Create the GUI application main window Add WidgetsEnter the main event loop import tkinter window = tkinter.Tk() # to rename the title of the window window.title("GUI") # pack is used to show the object in the window label = tkinter.Label(window, text = "Hello World!").pack() window.mainloop()
  • 13. Python Certification Training https://www.edureka.co/python Tkinter Widgets Tkinter
  • 14. Python Certification Training https://www.edureka.co/python Adding Widgets To Our Application A widget is an element of a graphical user interface (GUI) that displays information or provides a specific way for a user to interact with the operating system or an application Label Button Entry ComboBox CheckButton Radio ScrolledText SpinBox Menu Bar Notebook
  • 15. Python Certification Training https://www.edureka.co/python Label Widget Label You can set the label font so you can make it bigger and maybe bold l1 = Label (window, text="edureka!“ font=("Arial Bold", 50)) l1.grid (column=0, row=0) Changing the font style and size Output: Example:
  • 16. Python Certification Training https://www.edureka.co/python Label Widget Label We can set the default window size using geometry function Example: l1 = Label (window, text="edureka!“ font=("Arial Bold", 50)) window.geometry('350x200') l1.grid (column=0, row=0) The above line sets the window width to 350 pixels and the height to 200 pixels Output:
  • 17. Python Certification Training https://www.edureka.co/python Button Widget Button Let’s start by adding the button to the window, the button is created and added to the window the same as the label Example: Output: bt = Button (window, text="Enter") bt.grid (column=1, row=0) Using grid function to set the button position
  • 18. Python Certification Training https://www.edureka.co/python Button Widget Button • You can change foreground for a button or any other widget using fg property. • Also, you can change the background color for any widget using bg property. Example: Output: bt = Button (window, text="Enter", bg="orange", fg="red") bt.grid (column=1, row=0) Changing the background and foreground color
  • 19. Python Certification Training https://www.edureka.co/python Button Widget Button • Let’s add button click event • First, we will write the function that we need to execute when the button is clicked Example: def clicked(): l1.configure (text="Button was clicked !!") bt = Button (window, text=“Enter”, command=clicked) Function that will execute the button click event Wiring the button with the function
  • 20. Python Certification Training https://www.edureka.co/python Entry Widget Entry In the previous Python GUI examples, we saw how to add simple widgets. Now let’s try getting the user input using Tkinter Entry class (Tkinter textbox) txt = Entry(window,width=10) txt.grid(column=1, row=0) def clicked(): res = "Welcome to " + txt.get() l1.configure(text= res) bt = Button (window, text=“Enter”, command=clicked) Creating a textbox using Tkinter Entry class Once the button is clicked show “Welcome to” concatenated with the entered text Example:
  • 21. Python Certification Training https://www.edureka.co/python Entry Widget Entry
  • 22. Python Certification Training https://www.edureka.co/python Combobox Widget Combobox Combobox Widgets are very easy to use and are widely used as well! Example: from tkinter.ttk import * combo = Combobox(window) combo['values']= (1, 2, 3, 4, 5, "Text") combo.current(3) combo.grid(column=0, row=0) Adding the combobox items using the tuple Setting the selected item
  • 23. Python Certification Training https://www.edureka.co/python Combobox Widget
  • 24. Python Certification Training https://www.edureka.co/python Checkbutton Widget Checkbutton To create a checkbutton widget, you can use Checkbutton class Example: chk_state = BooleanVar() chk_state.set (True) chk = Checkbutton(window, text=‘Select', var=chk_state) chk.grid(column=0, row=0) Creating a variable of type BooleanVar which is not a standard Python variable, it’s a Tkinter variable Passing the chk_state to the Checkbutton class to set the check state
  • 25. Python Certification Training https://www.edureka.co/python Checkbutton Widget Checkbutton
  • 26. Python Certification Training https://www.edureka.co/python Radio Button Widget Radio Button To add radio buttons, simply you can use RadioButton class Example: rad1 = Radiobutton(window, text=Python', value=1) rad2 = Radiobutton(window, text=Java', value=2) rad3 = Radiobutton(window, text=Scala', value=3) rad1.grid(column=0, row=0) rad2.grid(column=1, row=0) rad3.grid(column=2, row=0) You should set the value for every radio button with a different value, otherwise, they won’t work
  • 27. Python Certification Training https://www.edureka.co/python Radio Button Widget Radio Button
  • 28. Python Certification Training https://www.edureka.co/python ScrolledText Widget ScrolledText To add a ScrolledText widget, you can use the ScrolledText class from tkinter import scrolledtext txt = scrolledtext.ScrolledText(window, width=40,height=10) Here we specify the width and the height of the ScrolledText widget, otherwise, it will fill the entire window To set scrolledtext content, you can use the insert method - txt.insert(INSERT,'You text goes here') Example:
  • 29. Python Certification Training https://www.edureka.co/python MessageBox Widget MessageBox To show a message box using Tkinter, you can use messagebox library Example: from tkinter import messagebox messagebox.showinfo('Message title’, 'Message content') def clicked(): messagebox.showinfo('Message title', 'Message content') btn = Button(window,text=‘ENTER', command=clicked) Example: Shows a message box when the user clicks a button
  • 30. Python Certification Training https://www.edureka.co/python MessageBox Widget MessageBox
  • 31. Python Certification Training https://www.edureka.co/python SpinBox Widget SpinBox To create a Spinbox widget, you can use the Spinbox class spin = Spinbox(window, from_=0, to=100, width=5) Output:Example:
  • 32. Python Certification Training https://www.edureka.co/python Geometry Management Tkinter
  • 33. Python Certification Training https://www.edureka.co/python Geometry Management All tkinter widgets will have geometric measurements pack() grid() place() It organizes the widgets in the block, which mean it occupies the entire available width It organizes the widgets in table-like structure It's used to place the widgets at a specific position you want. Geometry Manager Classes
  • 34. Python Certification Training https://www.edureka.co/python Organizing Layout & Widgets Tkinter
  • 35. Python Certification Training https://www.edureka.co/python Organizing Layout And Widgets We use Frame class to arrange layout in a window Frame is used to create the divisions in the window. You can align the frames as you like with side parameter of pack() method. Button is used to create a button in the window. It takes several parameters like text(Value of the Button), fg(Color of the text), bg(Background color) Frame Button Let’s see some code
  • 36. Python Certification Training https://www.edureka.co/python Organizing Layout And Widgets Sample Login Box Grid is another way to organize the widgets. It uses the Matrix row column concepts. Grid Let’s see more code
  • 37. Python Certification Training https://www.edureka.co/python Binding Functions Tkinter
  • 38. Python Certification Training https://www.edureka.co/python Binding Functions Calling functions whenever an event occurs refers to a binding function. Binding I like code! import tkinter window = tkinter.Tk() window.title("GUI") # creating a function called say_hi() def say_hi(): tkinter.Label(window, text = "Hi").pack() tkinter.Button(window, text = "Click Me!", command = say_hi).pack() window.mainloop()
  • 39. Python Certification Training https://www.edureka.co/python Event Handling Tkinter
  • 40. Python Certification Training https://www.edureka.co/python Event Handling mousemove, mouseover, clicking, scrolling are some eventsEvents <Button-1> <Button-2> <Button-3> Left Click Middle Click Right Click Mouse Buttons
  • 41. Python Certification Training https://www.edureka.co/python Images & Icons Tkinter
  • 42. Python Certification Training https://www.edureka.co/python Images & Icons Images can be added using the PhotoImage methodAdd Images We love Edureka <3
  • 43. Python Certification Training https://www.edureka.co/python Use Case Tkinter
  • 44. Python Certification Training https://www.edureka.co/python Let us design our own basic calculator using tkinter Use Case – Simple Calculator
  • 45. Python Certification Training https://www.edureka.co/python Conclusion Tkinter
  • 46. Python Certification Training https://www.edureka.co/python Conclusion I learnt Tkinter, yay!