0% found this document useful (0 votes)
2 views70 pages

Unit 1

The document is a tutorial on Tkinter, a standard library in Python for creating graphical user interfaces for desktop applications. It covers basic and advanced concepts, including various widgets like buttons, labels, and entry fields, as well as geometry management methods such as pack(), grid(), and place(). Additionally, it provides syntax and options for using specific widgets like Button, Canvas, Checkbutton, and Entry.

Uploaded by

disecek477
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views70 pages

Unit 1

The document is a tutorial on Tkinter, a standard library in Python for creating graphical user interfaces for desktop applications. It covers basic and advanced concepts, including various widgets like buttons, labels, and entry fields, as well as geometry management methods such as pack(), grid(), and place(). Additionally, it provides syntax and options for using specific widgets like Button, Canvas, Checkbutton, and Entry.

Uploaded by

disecek477
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

UNIT-1 TKINTER WIDGET

Introduction

Tkinter tutorial provides basic and advanced concepts of Python Tkinter. Our Tkinter tutorial
is designed for beginners and professionals.

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.

Tkinter widgets
There are various widgets like button, canvas, checkbutton, entry, etc. that are used to build
the python GUI applications.

SN Widget Description

The Button is used to


add various kinds of
1 Button
buttons to the python
application.

The canvas widget is


2 Canvas used to draw the canvas
on the window.

The Checkbutton is
used to display the
3 Checkbutton
CheckButton on the
window.

The entry widget is used


4 Entry
to display the single-line
text field to the user. It is
UNIT-1 TKINTER WIDGET

commonly used to
accept user values.

It can be defined as a
container to which,
5 Frame
another widget can be
added and organized.

A label is a text used to


display some message
6 Label
or information about the
other widgets.

The ListBox widget is


7 ListBox used to display a list of
options to the user.

The Menubutton is used


8 Menubutton to display the menu
items to the user.

It is used to add menu


9 Menu
items to the user.

The Message widget is


used to display the
10 Message
message-box to the
user.

The Radiobutton is
different from a
checkbutton. Here, the
11 Radiobutton user is provided with
various options and the
user can select only one
option among them.
UNIT-1 TKINTER WIDGET

It is used to provide the


12 Scale
slider to the user.

It provides the scrollbar


to the user so that the
13 Scrollbar
user can scroll the
window up and down.

It is different from Entry


because it provides a
multi-line text field to the
14 Text
user so that the user
can write the text and
edit the text inside it.

It is used to create a
14 Toplevel separate window
container.

It is an entry widget
15 Spinbox used to select from
options of values.

It is like a container
widget that contains
16 PanedWindow
horizontal or vertical
panes.

A LabelFrame is a
17 LabelFrame container widget that
acts as the container

This module is used to


display the message-
18 MessageBox
box in the desktop
based applications.
UNIT-1 TKINTER WIDGET

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.

1. The pack() method


2. The grid() method
3. The place() method

Let's discuss each one of them in detail.

Python Tkinter pack() 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.

The syntax to use the pack() is given below.

syntax
widget.pack(options)

A list of possible options that can be passed in pack() is given below.

o expand: If the expand is set to true, the widget expands to fill any space.
o Fill: By default, the fill is set to NONE. However, we can set it to X or Y to determine
whether the widget contains any extra space.
o size: it represents the side of the parent to which the widget is to be placed on the window.

Python Tkinter grid() method


The grid() geometry manager organizes the widgets in the tabular form. We can specify the
rows and columns as the options in the method call. We can also specify the column span
(width) or rowspan(height) of a widget.

This is a more organized way to place the widgets to the python application. The syntax to
use the grid() is given below.

Syntax
1. widget.grid(options)
A list of possible options that can be passed inside the grid() method is given below.

o Column
The column number in which the widget is to be placed. The leftmost column is
represented by 0.
o Columnspan
The width of the widget. It represents the number of columns up to which, the column is
expanded.
UNIT-1 TKINTER WIDGET

o ipadx, ipady
It represents the number of pixels to pad the widget inside the widget's border.
o padx, pady
It represents the number of pixels to pad the widget outside the widget's border.
o row
The row number in which the widget is to be placed. The topmost row is represented by
0.
o rowspan
The height of the widget, i.e. the number of the row up to which the widget is expanded.
o Sticky
If the cell is larger than a widget, then sticky is used to specify the position of the widget
inside the cell. It may be the concatenation of the sticky letters representing the position
of the widget. It may be N, E, W, S, NE, NW, NS, EW, ES.

Python Tkinter place() method


The place() geometry manager organizes the widgets to the specific x and y coordinates.

Syntax
widget.place(options)

A list of possible options is given below.

o Anchor: It represents the exact position of the widget within the container. The default
value (direction) is NW (the upper left corner)
o bordermode: The default value of the border type is INSIDE that refers to ignore the
parent's inside the border. The other option is OUTSIDE.
o height, width: It refers to the height and width in pixels.
o relheight, relwidth: It is represented as the float between 0.0 and 1.0 indicating the
fraction of the parent's height and width.
o relx, rely: It is represented as the float between 0.0 and 1.0 that is the offset in the
horizontal and vertical direction.
o x, y: It refers to the horizontal and vertical offset in the pixels.

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.

The syntax to use the button widget is given below.

Syntax
W = Button(parent, options)
UNIT-1 TKINTER WIDGET

Options
It represents the
background of the
1 activebackground button when the
mouse hover the
button.

It represents the font


color of the button
2 activeforeground
when the mouse
hover the button.

It represents the
3 Bd
border width in pixels.

It represents the
4 Bg background color of
the button.

It is set to the function


call which is
5 Command
scheduled when the
function is called.

Foreground color of
6 Fg
the button.

The font of the button


7 Font
text.

The height of the


button. The height is
represented in the
8 Height number of text lines
for the textual lines or
the number of pixels
for the images.
UNIT-1 TKINTER WIDGET

The color of the


10 Highlightcolor highlight when the
button has the focus.

It is set to the image


11 Image displayed on the
button.

It illustrates the way


by which the multiple
text lines are
represented. It is set
12 justify to LEFT for left
justification, RIGHT for
the right justification,
and CENTER for the
center.

Additional padding to
13 Padx the button in the
horizontal direction.

Additional padding to
14 pady the button in the
vertical direction.

It represents the type


of the border. It can be
15 Relief SUNKEN, RAISED,
GROOVE, and
RIDGE.

This option is set to


DISABLED to make
the button
17 State unresponsive. The
ACTIVE represents
the active state of the
button.
UNIT-1 TKINTER WIDGET

Set this option to


18 Underline make the button text
underlined.

The width of the


button. It exists as a
number of letters for
19 Width
textual buttons or
pixels for image
buttons.

If the value is set to a


positive number, the
20 Wraplength text lines will be
wrapped to fit within
this length.

Python Tkinter Canvas


The canvas widget is used to add the structured graphics to the python application. It is used
to draw the graph and plots to the python application. The syntax to use the canvas is given
below.

Syntax
w = canvas(parent, options)

Options
The represents the
1 bd border width. The
default width is 2.

It represents the
2 bg background color of
the canvas.

3 confine It is set to make the


canvas unscrollable
UNIT-1 TKINTER WIDGET

outside the scroll


region.

The cursor is used as


4 cursor the arrow, circle, dot,
etc. on the canvas.

It represents the size


5 height of the canvas in the
vertical direction.

It represents the
6 highlightcolor highlight color when
the widget is focused.

It represents the type


of the border. The
possible values are
7 relief
SUNKEN, RAISED,
GROOVE, and
RIDGE.

It represents the
coordinates specified
8 scrollregion as the tuple containing
the area of the
canvas.

It represents the width


9 width
of the canvas.

If it is set to a positive
value. The canvas is
10 xscrollincrement
placed only to the
multiple of this value.

11 xscrollcommand If the canvas is


scrollable, this
UNIT-1 TKINTER WIDGET

attribute should be the


.set() method of the
horizontal scrollbar.

Works like
xscrollincrement, but
12 yscrollincrement
governs vertical
movement.

If the canvas is
scrollable, this
13 yscrollcommand attribute should be the
.set() method of the
vertical scrollbar.

Python Tkinter Checkbutton


The Checkbutton is used to track the user's choices provided to the application. In other
words, we can say that Checkbutton is used to implement the on/off selections.

The Checkbutton can contain the text or images. The Checkbutton is mostly used to provide
many choices to the user among which, the user needs to choose the one. It generally
implements many of many selections.

The syntax to use the checkbutton is given below.

Syntax
w = checkbutton(master, options)
Options
It represents the
background color when
1 activebackground
the checkbutton is under
the cursor.

It represents the
2 activeforeground
foreground color of the
checkbutton when the
UNIT-1 TKINTER WIDGET

checkbutton is under the


cursor.

The background color of


3 bg
the button.

It displays an image
4 bitmap (monochrome) on the
button.

The size of the border


5 bd
around the corner.

It is associated with a
function to be called
6 command
when the state of the
checkbutton is changed.

The mouse pointer will


be changed to the
7 cursor
cursor name when it is
over the checkbutton.

It is the color which is


used to represent the
8 disableforeground
text of a disabled
checkbutton.

It represents the font of


9 font
the checkbutton.

The foreground color


10 fg (text color) of the
checkbutton.

11 height It represents the height


of the checkbutton
UNIT-1 TKINTER WIDGET

(number of lines). The


default height is 1.

The color of the focus


highlight when the
12 highlightcolor
checkbutton is under
focus.

The image used to


13 image represent the
checkbutton.

This specifies the


justification of the text if
14 justify
the text contains
multiple lines.

The associated control


variable is set to 0 by
default if the button is
15 offvalue unchecked. We can
change the state of an
unchecked variable to
some other one.

The associated control


variable is set to 1 by
default if the button is
16 onvalue checked. We can
change the state of the
checked variable to
some other one.

The horizontal padding


17 padx
of the checkbutton

The vertical padding of


18 pady
the checkbutton.
UNIT-1 TKINTER WIDGET

The type of the border of


19 relief the checkbutton. By
default, it is set to FLAT.

The color of the


20 selectcolor checkbutton when it is
set. By default, it is red.

The image is shown on


21 selectimage the checkbutton when it
is set.

It represents the state of


the checkbutton. By
default, it is set to
normal. We can change
it to DISABLED to make
22 state
the checkbutton
unresponsive. The state
of the checkbutton is
ACTIVE when it is under
focus.

It represents the index


of the character in the
text which is to be
24 underline
underlined. The indexing
starts with zero in the
text.

It represents the
associated variable that
25 variable
tracks the state of the
checkbutton.

It represents the width of


26 width the checkbutton. It is
represented in the
number of characters
UNIT-1 TKINTER WIDGET

that are represented in


the form of texts.

If this option is set to an


integer number, the text
27 wraplength
will be broken into the
number of pieces.

Methods
It is called to turn off
1 deselect()
the checkbutton.

The checkbutton is
flashed between the
2 flash()
active and normal
colors.

This will invoke the


3 invoke() method associated
with the checkbutton.

It is called to turn on
4 select()
the checkbutton.

It is used to toggle
5 toggle() between the different
Checkbuttons.

Python Tkinter Entry


The Entry widget is used to provde the single line text-box to the user to accept a value from
the user. We can use the Entry widget to accept the text strings from the user. It can only be
used for one line of text from the user. For multiple lines of text, we must use the text widget.

The syntax to use the Entry widget is given below.


UNIT-1 TKINTER WIDGET

Syntax
w = Entry (parent, options)
Options
The background color
1 bg
of the widget.

The border width of


2 bd
the widget in pixels.

The mouse pointer


will be changed to the
3 cursor
cursor type set to the
arrow, dot, etc.

The text written inside


the entry box will be
automatically copied
4 exportselection to the clipboard by
default. We can set
the exportselection to
0 to not copy this.

It represents the color


5 fg
of the text.

It represents the font


6 font
type of the text.

It represents the color


to display in the
traversal highlight
7 highlightbackground
region when the
widget does not have
the input focus.

It represents the color


8 highlightcolor
to use for the
traversal highlight
UNIT-1 TKINTER WIDGET

rectangle that is
drawn around the
widget when it has
the input focus.

It represents a non-
negative value
indicating the width of
the highlight rectangle
9 highlightthickness
to draw around the
outside of the widget
when it has the input
focus.

It represents the color


to use as background
in the area covered
by the insertion
10 insertbackground cursor. This color will
normally override
either the normal
background for the
widget.

It represents a non-
negative value
indicating the width of
the 3-D border to
draw around the
11 insertborderwidth
insertion cursor. The
value may have any
of the forms
acceptable to
Tk_GetPixels.

It represents a non-
negative integer value
indicating the number
12 insertofftime
of milliseconds the
insertion cursor
should remain "off" in
each blink cycle. If
UNIT-1 TKINTER WIDGET

this option is zero,


then the cursor
doesn't blink: it is on
all the time.

Specifies a non-
negative integer value
indicating the number
13 insertontime of milliseconds the
insertion cursor
should remain "on" in
each blink cycle.

It represents the
value indicating the
total width of the
insertion cursor. The
14 insertwidth
value may have any
of the forms
acceptable to
Tk_GetPixels.

It specifies how the


text is organized if the
15 justify
text contains multiple
lines.

It specifies the type of


16 relief the border. Its default
value is FLAT.

The background color


17 selectbackground
of the selected text.

The width of the


border to display
18 selectborderwidth
around the selected
task.
UNIT-1 TKINTER WIDGET

The font color of the


19 selectforeground
selected task.

It is used to show the


entry text of some
other type instead of
20 show the string. For
example, the
password is typed
using stars (*).

It is set to the
instance of the
21 textvariable StringVar to retrieve
the text from the
entry.

The width of the


22 width displayed text or
image.

The entry widget can


be linked to the
horizontal scrollbar if
23 xscrollcommand we want the user to
enter more text then
the actual width of the
widget.

Methods
It is used to delete the
1 delete(first, last = none) specified characters
inside the widget.

It is used to get the text


2 get() written inside the
widget.
UNIT-1 TKINTER WIDGET

It is used to change the


insertion cursor
position. We can
3 icursor(index)
specify the index of the
character before which,
the cursor to be placed.

It is used to place the


cursor to the left of the
4 index(index)
character written at the
specified index.

It is used to insert the


specified string before
5 insert(index,s)
the character placed at
the specified index.

It includes the selection


of the character
6 select_adjust(index)
present at the specified
index.

It clears the selection if


7 select_clear() some selection has
been done.

It sets the anchor index


position to the
8 select_form(index)
character specified by
the index.

It returns true if some


text in the Entry is
9 select_present()
selected otherwise
returns false.
UNIT-1 TKINTER WIDGET

It selects the characters


10 select_range(start,end) to exist between the
specified range.

It selects all the


characters from the
11 select_to(index)
beginning to the
specified index.

It is used to link the


12 xview(index) entry widget to a
horizontal scrollbar.

It is used to make the


13 xview_scroll(number,what) entry scrollable
horizontally.

Python Tkinter Frame


Python Tkinter Frame widget is used to organize the group of widgets. It acts like a container
which can be used to hold the other widgets. The rectangular areas of the screen are used
to organize the widgets to the python application.

The syntax to use the Frame widget is given below.

Syntax
w = Frame(parent, options)
Options
It represents the border
1 bd
width.

The background color of


2 bg
the widget.

3 cursor The mouse pointer is


changed to the cursor
UNIT-1 TKINTER WIDGET

type set to different


values like an arrow, dot,
etc.

4 height The height of the frame.

The color of the


5 highlightbackground background color when it
is under focus.

The text color when the


6 highlightcolor
widget is under focus.

It specifies the thickness


around the border when
7 highlightthickness
the widget is under the
focus.

It specifies the type of the


8 relief border. The default value
if FLAT.

It represents the width of


9 width
the widget.

Python Tkinter Label


The Label is used to specify the container box where we can place the text or images. This
widget is used to provide the message to the user about other widgets used in the python
application.

There are the various options which can be specified to configure the text or the part of the
text shown in the Label.

The syntax to use the Label is given below.


UNIT-1 TKINTER WIDGET

Syntax
w = Label (master, options)
Options
It specifies the exact
position of the text
within the size
provided to the widget.
1 anchor The default value is
CENTER, which is
used to center the text
within the specified
space.

The background color


2 bg displayed behind the
widget.

It is used to set the


bitmap to the
graphical object
3 bitmap specified so that, the
label can represent
the graphics instead of
text.

It represents the width


4 bd of the border. The
default is 2 pixels.

The mouse pointer will


be changed to the
5 cursor type of the cursor
specified, i.e., arrow,
dot, etc.

The font type of the


6 font text written inside the
widget.
UNIT-1 TKINTER WIDGET

The foreground color


7 fg of the text written
inside the widget.

The height of the


8 height
widget.

The image that is to


9 image
be shown as the label.

It is used to represent
the orientation of the
text if the text contains
multiple lines. It can
10 justify be set to LEFT for left
justification, RIGHT for
right justification, and
CENTER for center
justification.

The horizontal
11 padx padding of the text.
The default value is 1.

The vertical padding


12 pady of the text. The default
value is 1.

The type of the


13 relief border. The default
value is FLAT.

This is set to the string


variable which may
14 text
contain one or more
line of text.
UNIT-1 TKINTER WIDGET

The text written inside


the widget is set to the
control variable
15 textvariable
StringVar so that it
can be accessed and
changed accordingly.

We can display a line


under the specified
letter of the text. Set
16 underline this option to the
number of the letter
under which the line
will be displayed.

The width of the


widget. It is specified
17 width
as the number of
characters.

Instead of having only


one line as the label
text, we can break it to
the number of lines
18 wraplength
where each line has
the number of
characters specified to
this option.

Python Tkinter Listbox


The Listbox widget is used to display the list items to the user. We can place only text items
in the Listbox and all text items contain the same font and color.

The user can choose one or more items from the list depending upon the configuration.

The syntax to use the Listbox is given below.

w = Listbox(parent, options)
Options
UNIT-1 TKINTER WIDGET

The background color of


1 bg
the widget.

It represents the size of


2 bd the border. Default value
is 2 pixel.

The mouse pointer will


3 cursor look like the cursor type
like dot, arrow, etc.

The font type of the


4 font
Listbox items.

5 fg The color of the text.

It represents the count


of the lines shown in the
6 height
Listbox. The default
value is 10.

The color of the Listbox


7 highlightcolor items when the widget is
under focus.

The thickness of the


8 highlightthickness
highlight.

The type of the border.


9 relief
The default is SUNKEN.

The background color


10 selectbackground that is used to display
the selected text.
UNIT-1 TKINTER WIDGET

It is used to determine
the number of items that
can be selected from the
11 selectmode list. It can set to
BROWSE, SINGLE,
MULTIPLE,
EXTENDED.

It represents the width of


12 width
the widget in characters.

It is used to let the user


13 xscrollcommand scroll the Listbox
horizontally.

It is used to let the user


14 yscrollcommand scroll the Listbox
vertically.

Methods
It is used to select the
1 activate(index) lines at the specified
index.

It returns a tuple
containing the line
numbers of the selected
2 curselection() element or elements,
counting from 0. If
nothing is selected,
returns an empty tuple.

It is used to delete the


3 delete(first, last = None) lines which exist in the
given range.
UNIT-1 TKINTER WIDGET

It is used to get the list


4 get(first, last = None) items that exist in the
given range.

It is used to place the line


5 index(i) with the specified index
at the top of the widget.

It is used to insert the


new lines with the
6 insert(index, *elements) specified number of
elements before the
specified index.

It returns the index of


the nearest line to the y
7 nearest(y)
coordinate of the Listbox
widget.

It is used to adjust the


position of the listbox to
8 see(index)
make the lines specified
by the index visible.

It returns the number of


9 size() lines that are present in
the Listbox widget.

This is used to make the


10 xview() widget horizontally
scrollable.

It is used to make the


11 xview_moveto(fraction) listbox horizontally
scrollable by the fraction
of width of the longest
UNIT-1 TKINTER WIDGET

line present in the


listbox.

It is used to make the


listbox horizontally
12 xview_scroll(number, what)
scrollable by the number
of characters specified.

It allows the Listbox to be


13 yview()
vertically scrollable.

It is used to make the


listbox vertically
scrollable by the fraction
14 yview_moveto(fraction)
of width of the longest
line present in the
listbox.

It is used to make the


listbox vertically
15 yview_scroll (number, what)
scrollable by the number
of characters specified.

Python Tkinter Menubutton


The Menubutton widget can be defined as the drop-down menu that is shown to the user all
the time. It is used to provide the user a option to select the appropriate choice exist within
the application.

The Menubutton is used to implement various types of menus in the python application. A
Menu is associated with the Menubutton that can display the choices of the Menubutton when
clicked by the user.

The syntax to use the python tkinter Menubutton is given below.

Syntax
w = Menubutton(Top, options)

Options
UNIT-1 TKINTER WIDGET

The background color


1 activebackground of the widget when the
widget is under focus.

The font color of the


2 activeforeground widget text when the
widget is under focus.

It specifies the exact


position of the widget
content when the
3 anchor
widget is assigned
more space than
needed.

It specifies the
4 bg background color of
the widget.

It is set to the
graphical content
5 bitmap which is to be
displayed to the
widget.

It represents the size


of the border. The
6 bd
default value is 2
pixels.

The mouse pointer will


be changed to the
cursor type specified
when the widget is
7 cursor
under the focus. The
possible value of the
cursor type is arrow,
or dot etc.
UNIT-1 TKINTER WIDGET

It direction can be
specified so that menu
can be displayed to
the specified direction
8 direction
of the button. Use
LEFT, RIGHT, or
ABOVE to place the
widget accordingly.

The text color of the


9 disabledforeground widget when the
widget is disabled.

The normal
10 fg foreground color of the
widget.

The vertical dimension


of the Menubutton. It
11 height
is specified as the
number of lines.

The highlight color


12 highlightcolor shown to the widget
under focus.

The image displayed


13 image
on the widget.

This specified the


exact position of the
text under the widget
when the text is
14 justify unable to fill the width
of the widget. We can
use the LEFT for the
left justification,
RIGHT for the right
justification, CENTER
UNIT-1 TKINTER WIDGET

for the centre


justification.

It represents the menu


15 menu specified with the
Menubutton.

The horizontal
16 padx
padding of the widget.

The vertical padding


17 pady
of the widget.

This option specifies


the type of the border.
18 relief
The default value is
RAISED.

The normal state of


the Mousebutton is
19 state enabled. We can set it
to DISABLED to make
it unresponsive.

The text shown with


20 text
the widget.

We can set the control


variable of string type
to the text variable so
21 textvariable
that we can control the
text of the widget at
runtime.

The text of the widget


22 underline is not underlined by
default but we can set
this option to make the
UNIT-1 TKINTER WIDGET

text of the widget


underlined.

It represents the width


of the widget in
23 width
characters. The
default value is 20.

We can break the text


of the widget in the
number of lines so
24 wraplength that the text contains
the number of lines
not greater than the
specified value.

Python Tkinter Menu


The Menu widget is used to create various types of menus (top level, pull down, and pop up)
in the python application.

The top-level menus are the one which is displayed just under the title bar of the parent
window. We need to create a new instance of the Menu widget and add various commands
to it by using the add() method.

The syntax to use the Menu widget is given below.

Syntax
w = Menu(top, options)

Options
The background color of
the widget when the
1 activebackground
widget is under the
focus.

2 activeborderwidth The width of the border


of the widget when it is
UNIT-1 TKINTER WIDGET

under the mouse. The


default is 1 pixel.

The font color of the


3 activeforeground widget when the widget
has the focus.

The background color of


4 bg
the widget.

The border width of the


5 bd
widget.

The mouse pointer is


changed to the cursor
type when it hovers the
6 cursor
widget. The cursor type
can be set to arrow or
dot.

The font color of the


7 disabledforeground widget when it is
disabled.

The font type of the text


8 font
of the widget.

The foreground color of


9 fg
the widget.

The postcommand can


be set to any of the
10 postcommand function which is called
when the mourse hovers
the menu.
UNIT-1 TKINTER WIDGET

The type of the border of


11 relief the widget. The default
type is RAISED.

It is used to display an
12 image
image on the menu.

The color used to


display the checkbutton
13 selectcolor
or radiobutton when
they are selected.

By default, the choices


in the menu start taking
place from position 1. If
14 tearoff
we set the tearoff = 1,
then it will start taking
place from 0th position.

Set this option to the title


of the window if you
15 title
want to change the title
of the window.

Methods

It is used to add the


1 add_command(options) Menu items to the
menu.

This method adds


2 add_radiobutton(options) the radiobutton to
the menu.

3 add_checkbutton(options) This method is used


to add the
UNIT-1 TKINTER WIDGET

checkbuttons to the
menu.

It is used to create a
hierarchical menu to
the parent menu by
4 add_cascade(options)
associating the
given menu to the
parent menu.

It is used to add the


5 add_seperator() seperator line to the
menu.

It is used to add the


6 add(type, options) specific menu item
to the menu.

It is used to delete
the menu items
7 delete(startindex, endindex)
exist in the specified
range.

It is used to
configure a menu
8 entryconfig(index, options)
item identified by
the given index.

It is used to get the


index of the
9 index(item)
specified menu
item.

It is used to insert a
10 insert_seperator(index) seperator at the
specified index.
UNIT-1 TKINTER WIDGET

It is used to invoke
the associated with
11 invoke(index)
the choice given at
the specified index.

It is used to get the


type of the choice
12 type(index)
specified by the
index.

Python Tkinter Message


The Message widget is used to show the message to the user regarding the behaviour of the
python application. The message widget shows the text messages to the user which can not
be edited.

The message text contains more than one line. However, the message can only be shown in
the single font.

The syntax to use the Message widget is given below.

Syntax
w = Message(parent, options)
Options
It is used to decide the
exact position of the
text within the space
provided to the widget
1 anchor
if the widget contains
more space than the
need of the text. The
default is CENTER.

The background color


2 bg
of the widget.

It is used to display
3 bitmap
the graphics on the
widget. It can be set to
UNIT-1 TKINTER WIDGET

any graphical or
image object.

It represents the size


of the border in the
4 bd
pixel. The default size
is 2 pixel.

The mouse pointer is


changed to the
5 cursor specified cursor type.
The cursor type can
be an arrow, dot, etc.

The font type of the


6 font
widget text.

The font color of the


7 fg
widget text.

The vertical dimension


8 height
of the message.

We can set this option


to a static image to
9 image
show that onto the
widget.

This option is used to


specify the alignment
of multiple line of code
with respect to each
other. The possible
10 justify
values can be LEFT
(left alignment),
CENTER (default),
and RIGHT (right
alignment).
UNIT-1 TKINTER WIDGET

The horizontal
11 padx
padding of the widget.

The vertical padding


12 pady
of the widget.

It represents the type


13 relief of the border. The
default type is FLAT.

We can set this option


to the string so that
14 text the widget can
represent the
specified text.

This is used to control


the text represented
by the widget. The
15 textvariable
textvariable can be set
to the text that is
shown in the widget.

The default value of


this option is -1 that
represents no
underline. We can set
16 underline this option to an
existing number to
specify that nth letter
of the string will be
underlined.

It specifies the
horizontal dimension
17 width of the widget in the
number of characters
(not pixel).
UNIT-1 TKINTER WIDGET

We can wrap the text


to the number of lines
by setting this option
18 wraplength to the desired number
so that each line
contains only that
number of characters.

Python Tkinter Radiobutton


The Radiobutton widget is used to implement one-of-many selection in the python application.
It shows multiple choices to the user out of which, the user can select only one out of them.
We can associate different methods with each of the radiobutton.

We can display the multiple line text or images on the radiobuttons. To keep track the user's
selection the radiobutton, it is associated with a single variable. Each button displays a single
value for that particular variable.

The syntax to use the Radiobutton is given below.

Syntax
w = Radiobutton(top, options)

Options
The background color of
1 activebackground the widget when it has
the focus.

The font color of the


2 activeforeground widget text when it has
the focus.

It represents the exact


position of the text within
the widget if the widget
3 anchor contains more space than
the requirement of the
text. The default value is
CENTER.
UNIT-1 TKINTER WIDGET

The background color of


4 bg
the widget.

It is used to display the


graphics on the widget. It
5 bitmap
can be set to any
graphical or image object.

It represents the size of


6 borderwidth
the border.

This option is set to the


procedure which must be
7 command called every-time when
the state of the
radiobutton is changed.

The mouse pointer is


changed to the specified
8 cursor
cursor type. It can be set
to the arrow, dot, etc.

It represents the font type


9 font
of the widget text.

The normal foreground


10 fg
color of the widget text.

The vertical dimension of


the widget. It is specified
11 height
as the number of lines
(not pixel).
UNIT-1 TKINTER WIDGET

It represents the color of


12 highlightcolor the focus highlight when
the widget has the focus.

The color of the focus


13 highlightbackground highlight when the widget
is not having the focus.

It can be set to an image


object if we want to
14 image display an image on the
radiobutton instead the
text.

It represents the
justification of the multi-
15 justify line text. It can be set to
CENTER(default), LEFT, or
RIGHT.

The horizontal padding of


16 padx
the widget.

The vertical padding of


17 pady
the widget.

The type of the border.


18 relief
The default value is FLAT.

The color of the radio


19 selectcolor
button when it is selected.

The image to be displayed


20 selectimage on the radiobutton when
it is selected.
UNIT-1 TKINTER WIDGET

It represents the state of


the radio button. The
default state of the
Radiobutton is NORMAL.
21 state
However, we can set this
to DISABLED to make the
radiobutton
unresponsive.

The text to be displayed


22 text
on the radiobutton.

It is of String type that


23 textvariable represents the text
displayed by the widget.

The default value of this


option is -1, however, we
24 underline can set this option to the
number of character
which is to be underlined.

The value of each


radiobutton is assigned to
25 value
the control variable when
it is turned on by the user.

It is the control variable


which is used to keep
26 variable track of the user's choices.
It is shared among all the
radiobuttons.

The horizontal dimension


of the widget. It is
27 width
represented as the
number of characters.
UNIT-1 TKINTER WIDGET

We can wrap the text to


the number of lines by
setting this option to the
28 wraplength desired number so that
each line contains only
that number of
characters.

Methods
It is used to turn of the
1 deselect()
radiobutton.

It is used to flash the


radiobutton between
2 flash()
its active and normal
colors few times.

It is used to call any


procedure associated
3 invoke() when the state of a
Radiobutton is
changed.

It is used to select the


4 select()
radiobutton.

Python Tkinter Scale


The Scale widget is used to implement the graphical slider to the python application so that
the user can slide through the range of values shown on the slider and select the one among
them.

We can control the minimum and maximum values along with the resolution of the scale. It
provides an alternative to the Entry widget when the user is forced to select only one value
from the given range of values.

The syntax to use the Scale widget is given below.


UNIT-1 TKINTER WIDGET

Syntax
w = Scale(top, options)
Options
The background color
1 activebackground of the widget when it
has the focus.

The background color


2 bg
of the widget.

The border size of the


3 bd widget. The default is
2 pixel.

It is set to the
procedure which is
called each time
when we move the
4 command
slider. If the slider is
moved rapidly, the
callback is done when
it settles.

The mouse pointer is


changed to the cursor
5 cursor type assigned to this
option. It can be an
arrow, dot, etc.

If the control variable


used to control the
scale data is of string
type, this option is
6 digits
used to specify the
number of digits when
the numeric scale is
converted to a string.
UNIT-1 TKINTER WIDGET

The font type of the


7 font
widget text.

The foreground color


8 fg
of the text.

It is used to represent
9 from_ one end of the widget
range.

The highlight color


when the widget
10 highlightbackground
doesn't have the
focus.

The highlight color


11 highlighcolor when the widget has
the focus.

This can be set to


some text which can
be shown as a label
with the scale. It is
12 label shown in the top left
corner if the scale is
horizontal or the top
right corner if the
scale is vertical.

It represents the
length of the widget. It
represents the X
13 length dimension if the scale
is horizontal or y
dimension if the scale
is vertical.

14 orient It can be set to


horizontal or vertical
UNIT-1 TKINTER WIDGET

depending upon the


type of the scale.

It represents the type


15 relief of the border. The
default is FLAT.

This option tells the


duration up to which
the button is to be
pressed before the
16 repeatdelay
slider starts moving in
that direction
repeatedly. The
default is 300 ms.

It is set to the
smallest change
17 resolution
which is to be made
to the scale value.

The value of the scale


is shown in the text
form by default. We
18 showvalue
can set this option to
0 to suppress the
label.

It represents the
length of the slider
window along the
length of the scale.
19 sliderlength
The default is 30
pixels. However, we
can change it to the
appropriate value.

The scale widget is


20 state
active by default. We
can set this to
UNIT-1 TKINTER WIDGET

DISABLED to make it
unresponsive.

The focus cycles


through the scale
widgets by default.
21 takefocus
We can set this option
to 0 if we don't want
this to happen.

The scale values are


displayed on the
multiple of the
22 tickinterval
specified tick interval.
The default value of
the tickinterval is 0.

It represents a float or
integer value that
specifies the other
23 to
end of the range
represented by the
scale.

It represents the color


24 troughcolor
of the through.

It represents the
25 variable control variable for
the scale.

It represents the width


26 width of the through part of
the widget.

Methods
UNIT-1 TKINTER WIDGET

It is used to get the


1 get() current value of the
scale.

It is used to set the


2 set(value)
value of the scale.

Python Tkinter Scrollbar


The scrollbar widget is used to scroll down the content of the other widgets like listbox, text,
and canvas. However, we can also create the horizontal scrollbars to the Entry widget.

The syntax to use the Scrollbar widget is given below.

Syntax
w = Scrollbar(top, options)

Options
The background color
1 activebackground of the widget when it
has the focus.

The background color


2 bg
of the widget.

The border width of


3 bd
the widget.

It can be set to the


procedure associated
with the list which can
4 command
be called each time
when the scrollbar is
moved.

The mouse pointer is


5 cursor
changed to the cursor
type set to this option
UNIT-1 TKINTER WIDGET

which can be an
arrow, dot, etc.

It represents the
border width around
6 elementborderwidth the arrow heads and
slider. The default
value is -1.

The focus
highlighcolor when
7 Highlightbackground
the widget doesn't
have the focus.

The focus
highlighcolor when
8 highlighcolor
the widget has the
focus.

It represents the
9 highlightthickness thickness of the focus
highlight.

It is used to control
the behavior of the
scroll jump. If it set to
10 jump 1, then the callback is
called when the user
releases the mouse
button.

It can be set to
HORIZONTAL or
VERTICAL
11 orient
depending upon the
orientation of the
scrollbar.
UNIT-1 TKINTER WIDGET

This option tells the


duration up to which
the button is to be
pressed before the
12 repeatdelay
slider starts moving in
that direction
repeatedly. The
default is 300 ms.

The default value of


13 repeatinterval the repeat interval is
100.

We can tab the focus


through this widget by
default. We can set
14 takefocus
this option to 0 if we
don't want this
behavior.

It represents the color


15 troughcolor
of the trough.

It represents the
16 width
width of the scrollbar.

Methods
It returns the two
numbers a and b
1 get() which represents the
current position of the
scrollbar.

It is used to connect
the scrollbar to the
2 set(first, last)
other widget w. The
yscrollcommand or
xscrollcommand of the
UNIT-1 TKINTER WIDGET

other widget to this


method.

Python Tkinter Text


The Text widget is used to show the text data on the Python application. However, Tkinter
provides us the Entry widget which is used to implement the single line text box.

The Text widget is used to display the multi-line formatted text with various styles and
attributes. The Text widget is mostly used to provide the text editor to the user.

The Text widget also facilitates us to use the marks and tabs to locate the specific sections
of the Text. We can also use the windows and images with the Text as it can also be used to
display the formatted text.

The syntax to use the Text widget is given below.

Syntax
w = Text(top, options)

Options
The background color
1 bg
of the widget.

It represents the border


2 bd
width of the widget.

The mouse pointer is


changed to the
3 cursor
specified cursor type,
i.e. arrow, dot, etc.

The selected text is


exported to the
selection in the window
4 exportselection
manager. We can set
this to 0 if we don't want
the text to be exported.
UNIT-1 TKINTER WIDGET

The font type of the


5 font
text.

The text color of the


6 fg
widget.

The vertical dimension


7 height
of the widget in lines.

The highlightcolor when


8 highlightbackground the widget doesn't has
the focus.

The thickness of the


9 highlightthickness focus highlight. The
default value is 1.

The color of the focus


10 highlighcolor highlight when the
widget has the focus.

It represents the color


11 insertbackground
of the insertion cursor.

It represents the width


12 insertborderwidth of the border around the
cursor. The default is 0.

The time amount in


Milliseconds during
13 insertofftime which the insertion
cursor is off in the blink
cycle.

The time amount in


14 insertontime
Milliseconds during
which the insertion
UNIT-1 TKINTER WIDGET

cursor is on in the blink


cycle.

It represents the width


15 insertwidth
of the insertion cursor.

The horizontal padding


16 padx
of the widget.

The vertical padding of


17 pady
the widget.

The type of the border.


18 relief
The default is SUNKEN.

The background color


19 selectbackground
of the selected text.

The width of the border


20 selectborderwidth around the selected
text.

It specifies the amount


of vertical space given
21 spacing1
above each line of the
text. The default is 0.

This option specifies


how much extra vertical
space to add between
22 spacing2
displayed lines of text
when a logical line
wraps. The default is 0.

23 spacing3 It specifies the amount


of vertical space to
UNIT-1 TKINTER WIDGET

insert below each line of


the text.

It the state is set to


DISABLED, the widget
24 state becomes unresponsive
to the mouse and
keyboard unresponsive.

This option controls


how the tab character is
25 tabs
used to position the
text.

It represents the width


26 width of the widget in
characters.

This option is used to


wrap the wider lines into
multiple lines. Set this
option to the WORD to
wrap the lines after the
27 wrap word that fit into the
available space. The
default value is CHAR
which breaks the line
which gets too wider at
any character.

To make the Text


widget horizontally
scrollable, we can set
28 xscrollcommand
this option to the set()
method of Scrollbar
widget.

To make the Text


29 yscrollcommand
widget vertically
scrollable, we can set
UNIT-1 TKINTER WIDGET

this option to the set()


method of Scrollbar
widget.

Methods
This method is used to
delete(startindex,
1 delete the characters
endindex)
of the specified range.

It returns the
get(startindex,
2 characters present in
endindex)
the specified range.

It is used to get the


3 index(index) absolute index of the
specified index.

It is used to insert the


4 insert(index, string) specified string at the
given index.

It returns a boolean
value true or false
depending upon
5 see(index)
whether the text at the
specified index is
visible or not.

Tkinter Toplevel
The Toplevel widget is used to create and display the toplevel windows which are directly
managed by the window manager. The toplevel widget may or may not have the parent
window on the top of them.

The toplevel widget is used when a python application needs to represent some extra
information, pop-up, or the group of widgets on the new window.

The toplevel windows have the title bars, borders, and other window decorations.
UNIT-1 TKINTER WIDGET

Syntax:
w = Toplevel(options)
Options
It represents the
1 bg background color of
the window.

It represents the
2 bd border size of the
window.

The mouse pointer is


changed to the cursor
type set to the arrow,
3 cursor
dot, etc. when the
mouse is in the
window.

The text selected in


the text widget is
exported to be
selected to the
4 class_
window manager. We
can set this to 0 to
make this behavior
false.

The font type of the


5 font text inserted into the
widget.

The foreground color


6 fg
of the widget.

It represents the
7 height
height of the window.
UNIT-1 TKINTER WIDGET

It represents the type


8 relief
of the window.

It represents the width


9 width
of the window,

Methods
This method is used to
1 deiconify()
display the window.

It is used to show a
2 frame() system dependent
window identifier.

It is used to add this


window to the
3 group(window)
specified window
group.

It is used to convert
4 iconify() the toplevel window
into an icon.

It is used to mention a
protocol(name, function which will be
5
function) called for the specific
protocol.

It is used to get the


current state of the
window. Possible
6 state()
values are normal,
iconic, withdrawn, and
icon.

7 transient([master]) It is used to convert


this window to a
UNIT-1 TKINTER WIDGET

transient window
(temporary).

It is used to delete the


8 withdraw() window but doesn't
destroy it.

It is used to declare
9 maxsize(width, height) the maximum size for
the window.

It is used to declare
10 minsize(width, height) the minimum size for
the window.

It is used to define the


11 positionfrom(who)
position controller.

It is used to control
resizable(width, whether the window
12
height) can be resizable or
not.

It is used to define the


13 sizefrom(who)
size controller.

It is used to define the


14 title(string)
title for the window.

Python Tkinter Spinbox


The Spinbox widget is an alternative to the Entry widget. It provides the range of values to
the user, out of which, the user can select the one.

It is used in the case where a user is given some fixed number of values to choose from.
UNIT-1 TKINTER WIDGET

We can use various options with the Spinbox to decorate the widget. The syntax to use the
Spinbox is given below.

Syntax
w = Spinbox(top, options)
Options
The background color of
1 activebackground the widget when it has
the focus.

The background color of


2 bg
the widget.

The border width of the


3 bd
widget.

The associated callback


with the widget which is
4 command called each time the
state of the widget is
called.

The mouse pointer is


changed to the cursor
5 cursor
type assigned to this
option.

The background color of


6 disabledbackground the widget when it is
disabled.

The foreground color of


7 disabledforeground the widget when it is
disabled.

The normal foreground


8 fg
color of the widget.
UNIT-1 TKINTER WIDGET

The font type of the


9 font
widget content.

This option is used for


10 format the format string. It has
no default value.

It is used to show the


11 from_ starting range of the
widget.

It is used to specify the


justification of the multi-
12 justify
line widget content. The
default is LEFT.

It is used to specify the


13 relief type of the border. The
default is SUNKEN.

This option is used to


control the button auto
14 repeatdelay
repeat. The value is
given in milliseconds.

It is similar to
15 repeatinterval repeatdelay. The value
is given in milliseconds.

It represents the state of


the widget. The default
is NORMAL. The
16 state
possible values are
NORMAL, DISABLED,
or "readonly".

17 textvariable It is like a control


variable which is used
UNIT-1 TKINTER WIDGET

to control the behaviour


of the widget text.

It specify the maximum


limit of the widget value.
18 to
The other is specified by
the from_ option.

This option controls how


19 validate the widget value is
validated.

It is associated to the
function callback which
20 validatecommand
is used for the validation
of the widget content.

It represents the tuple


21 values containing the values for
this widget.

It is same as validation
22 vcmd
command.

It represents the width


23 width
of the widget.

This option wraps up


24 wrap the up and down button
the Spinbox.

This options is set to the


set() method of scrollbar
25 xscrollcommand
to make this widget
horizontally scrollable.
UNIT-1 TKINTER WIDGET

Methods
This method is used to
delete(startindex, delete the characters
1
endindex) present at the
specified range.

It is used to get the


get(startindex,
2 characters present in
endindex)
the specified range.

It is used to identify
the widget's element
3 identify(x, y)
within the specified
range.

It is used to get the


4 index(index) absolute value of the
given index.

This method is used to


5 insert(index, string) insert the string at the
specified index.

It is used to invoke the


6 invoke(element) callback associated
with the widget.

Tkinter PanedWindow
The PanedWindow widget acts like a Container widget which contains one or more child
widgets (panes) arranged horizontally or vertically. The child panes can be resized by the
user, by moving the separator lines known as sashes by using the mouse.

Each pane contains only one widget. The PanedWindow is used to implement the different
layouts in the python applications.

The syntax to use the PanedWindow is given below.


UNIT-1 TKINTER WIDGET

Syntax
w= PanedWindow(master, options)

Options

It represents
the background
color of the
1 bg
widget when it
doesn't have
the focus.

It represents
the 3D border
size of the
widget. The
default option
specifies that
the trough
2 bd
contains no
border whereas
the arrowheads
and slider
contain the 2-
pixel border
size.

It represents
the border
width of the
3 borderwidth
widget. The
default is 2
pixel.

The mouse
pointer is
changed to the
4 cursor specified cursor
type when it is
over the
window.
UNIT-1 TKINTER WIDGET

This option
represents the
distance
between the
handle and the
end of the
sash. For the
5 handlepad horizontal
orientation, it is
the distance
between the
top of the sash
and the handle.
The default is 8
pixels.

It represents
the size of the
handle. The
default size is 8
6 handlesize pixels.
However, the
handle will
always be a
square.

It represents
the height of
the widget. If
we do not
specify the
7 height
height, it will be
calculated by
the height of
the child
window.

8 orient The orient will be set to


HORIZONTAL if we want to place
the child windows side by side. It
can be set to VERTICAL if we want
UNIT-1 TKINTER WIDGET

to place the child windows from top


to bottom.

It represents
the type of the
9 relief
border. The
default is FLAT.

It represents
the padding to
10 sashpad be done around
each sash. The
default is 0.

It represents
the type of the
border around
11 sashrelief
each of the
sash. The
default is FLAT.

It represents
the width of the
12 sashwidth sash. The
default is 2
pixels.

It is set to True
to display the
13 showhandle handles. The
default value is
false.

It represents
the width of the
widget. If we
14 Width
don't specify
the width of the
widget, it will be
calculated by
UNIT-1 TKINTER WIDGET

the size of the


child widgets.

Methods

It is used to add a
1 add(child, options) window to the parent
window.

This method is used to


get(startindex,
2 get the text present at
endindex)
the specified range.

It is used to configure
3 config(options) the widget with the
specified options.

Tkinter LabelFrame
The LabelFrame widget is used to draw a border around its child widgets. We can also display
the title for the LabelFrame widget. It acts like a container which can be used to group the
number of interrelated widgets such as Radiobuttons.

This widget is a variant of the Frame widget which has all the features of a frame. It also can
display a label.

The syntax to use the LabelFrame widget is given below.

Syntax
w = LabelFrame(top, options)
Options

The background color


1 bg
of the widget.

It represents the size


2 bd
of the border shown
around the indicator.
UNIT-1 TKINTER WIDGET

The default is 2
pixels.

The default value of


3 Class the class is
LabelFrame.

This option is used to


specify which
colomap is to be used
for this widget. By
colormap, we mean
the 256 colors that
4 colormap
are used to form the
graphics. With this
option, we can reuse
the colormap of
another window on
this widget.

If this is set to true,


the LabelFrame
5 container becomes the
container widget. The
default value is false.

It can be set to a
cursor type, i.e.
arrow, dot, etc. the
6 cursor mouse pointer is
changed to the cursor
type when it is over
the widget.

It represents the
7 fg foreground color of
the widget.
UNIT-1 TKINTER WIDGET

It represents the font


8 font type of the widget
text.

It represents the
9 height
height of the widget.

It represents the
exact position of the
10 labelAnchor text within the widget.
The default is
NW(north-west)

It represents the
widget to be used for
the label. The frame
11 labelwidget
uses the text for the
label if no value
specified.

The color of the focus


highlight border when
12 highlightbackground
the widget doesn't
have the focus.

The color of the focus


13 highlightcolor highlight when the
widget has the focus.

The width of the focus


14 highlightthickness
highlight border.

The horizontal
15 padx
padding of the widget.

The vertical padding


16 pady
of the widget.
UNIT-1 TKINTER WIDGET

It represents the
border style. The
17 relief
default value is
GROOVE.

It represents the
18 text string containing the
label text.

19 width

Tkinter messagebox
The messagebox module is used to display the message boxes in the python applications.
There are the various functions which are used to display the relevant messages depending
upon the application requirements.

The syntax to use the messagebox is given below.

Syntax
1. messagebox.function_name(title, message [, options])
Parameters
o function_name: It represents an appropriate message box function.
o title: It is a string which is shown as a title of a message box.
o message: It is the string to be displayed as a message on the message box.
o options: There are various options which can be used to configure the message dialog
box.
The two options that can be used are default and parent.

1. default

The default option is used to mention the types of the default button, i.e. ABORT, RETRY, or
IGNORE in the message box.

2. parent

The parent option specifies the parent window on top of which, the message box is to be
displayed.
UNIT-1 TKINTER WIDGET

There is one of the following functions used to show the appropriate message boxes. All the
functions are used with the same syntax but have the specific functionalities.

1. showinfo()
The showinfo() messagebox is used where we need to show some relevant information to
the user.

2. showwarning()
This method is used to display the warning to the user.

3. showerror()
This method is used to display the error message to the user.

4. askquestion()
This method is used to ask some question to the user which can be answered in yes or no.

5. askokcancel()
This method is used to confirm the user's action regarding some application activity.

6. askyesno()
This method is used to ask the user about some action to which, the user can answer in yes
or no.

7. askretrycancel()
This method is used to ask the user about doing a particular task again or not.

You might also like