SlideShare a Scribd company logo
1 of 31
UNIT 4
tkinter
GUI for python
Python tkinter
Tkinter tutorial provides basic and advanced concepts of Python Tkinter.
Python provides the standard library Tkinter for creating the graphical user
interface for desktop based applications.
Developing desktop based applications with python Tkinter is not a
complex task. An empty Tkinter top-level window can be created by
using the following steps.
1. import the Tkinter module.
2. Create the main application window.
3. Add the widgets like labels, buttons, frames, etc. to the window.
4. Call the main event loop so that the actions can take place on the
user's computer screen.
OUTPUT:
Tkinter widgets
There are various widgets like button, canvas, checkbutton, entry, etc. that are
used to build the python GUI applications.
SN Widget Description
1 Button The Button is used to add various
kinds of buttons to the python
application.
2 Canvas The canvas widget is used to draw
the canvas on the window.
3 Checkbutton The Checkbutton is used to display
the CheckButton on the window.
4 Entry The entry widget is used to display
the single-line text field to the user.
It is commonly used to accept user
values.
5 Frame It can be defined as a container to
which, another widget can be
added and organized.
6 Label A label is a text used to
display some message or
information about the
other widgets.
7 ListBox The ListBox widget is used
to display a list of options
to the user.
8 Menubutton The Menubutton is used
to display the menu items
to the user.
9 Menu It is used to add menu
items to the user.
10 Message The Message widget is
used to display the
message-box to the user.
11 Radiobutton The Radiobutton is
different from a
checkbutton. Here, the
user is provided with
various options and the
user can select only one
option among them.
12 Scale It is used to provide the slider to
the user.
13 Scrollbar It provides the scrollbar to the
user so that the user can scroll
the window up and down.
14 Text It is different from Entry
because it provides a multi-line
text field to the user so that the
user can write the text and edit
the text inside it.
14 Toplevel It is used to create a separate
window container.
15 Spinbox It is an entry widget used to
select from options of values.
16 PanedWindow It is like a container widget that
contains horizontal or vertical
panes.
17 LabelFrame A LabelFrame is a container
widget that acts as the
container
18 MessageBox This module is used to display
the message-box in the desktop
based applications.
Python Tkinter Geometry
The Tkinter geometry specifies the method by using which, the widgets are
represented on display. The python Tkinter provides the following geometry
methods.
• The pack() method
• The grid() method
• The place() method
The pack() widget is used to organize widget in the block. The positions widgets
added to the python application using the pack() method can be controlled by
using the various options specified in the method call.
However, the controls are less and widgets are generally added in the less
organized manner.
Python Tkinter pack() method
Python Tkinter place() method
The place() geometry manager organizes the widgets to the specific x and y
coordinates.
Python Tkinter Button
The button widget is used to add various types of buttons to the python
application. Python allows us to configure the look of the button according to
our requirements. Various options can be set or reset depending upon the
requirements.
We can also associate a method or function with a button which is called
when the button is pressed.
Python Tkinter Checkbutton
from tkinter import *
top = Tk()
top.geometry("200x200")
checkvar1 = IntVar()
checkvar2 = IntVar()
checkvar3 = IntVar()
chkbtn1 = Checkbutton(top, text = "C", variable = checkvar1, onvalue = 1, offvalue =
0, height = 2, width = 10)
chkbtn2 = Checkbutton(top, text = "C++", variable = checkvar2, onvalue = 1, offvalue
= 0, height = 2, width = 10)
chkbtn3 = Checkbutton(top, text = "Java", variable = checkvar3, onvalue = 1, offvalu
e = 0, height = 2, width = 10)
chkbtn1.pack()
chkbtn2.pack()
chkbtn3.pack()
top.mainloop()

More Related Content

Similar to lec 9.pptx

Gui builder
Gui builderGui builder
Gui builderlearnt
 
tkinter final ppt.ppt
tkinter final ppt.ppttkinter final ppt.ppt
tkinter final ppt.pptKanuAgrawal2
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAhsanul Karim
 
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.pptxTrangNguyenThiHuyen6
 
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAPYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAMaulik Borsaniya
 
GUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptxGUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptxdvarshitha04
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinFormHock Leng PUAH
 
Report for DIGITAL CLOCK 12011042 Manoj.pdf
Report for DIGITAL  CLOCK 12011042 Manoj.pdfReport for DIGITAL  CLOCK 12011042 Manoj.pdf
Report for DIGITAL CLOCK 12011042 Manoj.pdfManojKumar533913
 
PYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPriyaSoundararajan1
 
GUI_using_QT_Designer_PyQT4
GUI_using_QT_Designer_PyQT4GUI_using_QT_Designer_PyQT4
GUI_using_QT_Designer_PyQT4zenonas
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01Ankit Dubey
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI WidgetsAhsanul Karim
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Ahsanul Karim
 

Similar to lec 9.pptx (20)

Python ppt
Python pptPython ppt
Python ppt
 
Gui builder
Gui builderGui builder
Gui builder
 
tkinter final ppt.ppt
tkinter final ppt.ppttkinter final ppt.ppt
tkinter final ppt.ppt
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
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
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAPYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
 
GUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptxGUI Programming using Tkinter-converted.pptx
GUI Programming using Tkinter-converted.pptx
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinForm
 
Android session 3
Android session 3Android session 3
Android session 3
 
Report for DIGITAL CLOCK 12011042 Manoj.pdf
Report for DIGITAL  CLOCK 12011042 Manoj.pdfReport for DIGITAL  CLOCK 12011042 Manoj.pdf
Report for DIGITAL CLOCK 12011042 Manoj.pdf
 
GUI -THESIS123
GUI -THESIS123GUI -THESIS123
GUI -THESIS123
 
SPF WinForm Programs
SPF WinForm ProgramsSPF WinForm Programs
SPF WinForm Programs
 
PYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.ppt
 
GUI_using_QT_Designer_PyQT4
GUI_using_QT_Designer_PyQT4GUI_using_QT_Designer_PyQT4
GUI_using_QT_Designer_PyQT4
 
AWT information
AWT informationAWT information
AWT information
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 

lec 9.pptx

  • 2. Python tkinter Tkinter tutorial provides basic and advanced concepts of Python Tkinter. Python provides the standard library Tkinter for creating the graphical user interface for desktop based applications. Developing desktop based applications with python Tkinter is not a complex task. An empty Tkinter top-level window can be created by using the following steps. 1. import the Tkinter module. 2. Create the main application window. 3. Add the widgets like labels, buttons, frames, etc. to the window. 4. Call the main event loop so that the actions can take place on the user's computer screen.
  • 4. Tkinter widgets There are various widgets like button, canvas, checkbutton, entry, etc. that are used to build the python GUI applications. SN Widget Description 1 Button The Button is used to add various kinds of buttons to the python application. 2 Canvas The canvas widget is used to draw the canvas on the window. 3 Checkbutton The Checkbutton is used to display the CheckButton on the window. 4 Entry The entry widget is used to display the single-line text field to the user. It is commonly used to accept user values. 5 Frame It can be defined as a container to which, another widget can be added and organized.
  • 5. 6 Label A label is a text used to display some message or information about the other widgets. 7 ListBox The ListBox widget is used to display a list of options to the user. 8 Menubutton The Menubutton is used to display the menu items to the user. 9 Menu It is used to add menu items to the user. 10 Message The Message widget is used to display the message-box to the user. 11 Radiobutton The Radiobutton is different from a checkbutton. Here, the user is provided with various options and the user can select only one option among them.
  • 6. 12 Scale It is used to provide the slider to the user. 13 Scrollbar It provides the scrollbar to the user so that the user can scroll the window up and down. 14 Text It is different from Entry because it provides a multi-line text field to the user so that the user can write the text and edit the text inside it. 14 Toplevel It is used to create a separate window container. 15 Spinbox It is an entry widget used to select from options of values. 16 PanedWindow It is like a container widget that contains horizontal or vertical panes. 17 LabelFrame A LabelFrame is a container widget that acts as the container 18 MessageBox This module is used to display the message-box in the desktop based applications.
  • 7. Python Tkinter Geometry The Tkinter geometry specifies the method by using which, the widgets are represented on display. The python Tkinter provides the following geometry methods. • The pack() method • The grid() method • The place() method
  • 8. The pack() widget is used to organize widget in the block. The positions widgets added to the python application using the pack() method can be controlled by using the various options specified in the method call. However, the controls are less and widgets are generally added in the less organized manner. Python Tkinter pack() method
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. Python Tkinter place() method The place() geometry manager organizes the widgets to the specific x and y coordinates.
  • 16.
  • 17. Python Tkinter Button The button widget is used to add various types of buttons to the python application. Python allows us to configure the look of the button according to our requirements. Various options can be set or reset depending upon the requirements. We can also associate a method or function with a button which is called when the button is pressed.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30. from tkinter import * top = Tk() top.geometry("200x200") checkvar1 = IntVar() checkvar2 = IntVar() checkvar3 = IntVar() chkbtn1 = Checkbutton(top, text = "C", variable = checkvar1, onvalue = 1, offvalue = 0, height = 2, width = 10) chkbtn2 = Checkbutton(top, text = "C++", variable = checkvar2, onvalue = 1, offvalue = 0, height = 2, width = 10) chkbtn3 = Checkbutton(top, text = "Java", variable = checkvar3, onvalue = 1, offvalu e = 0, height = 2, width = 10)

Editor's Notes

  1. Two programs on idle  tkbutton n tkbutton1
  2. Two programs  tkcanvas n tkarc