Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
tkinter

What are Tkinter widgets?

Umme Ammara

Python provides options to develop graphical user interfaces (GUI) using Tkinter. Tkinter is a standard GUI library for Python that helps with creating GUI applications.

Tkinter widgets

Tkinter provides controls, including text boxes, labels, buttons, etc. These controls are called widgets. There are fifteen types of widgets in Tkinter, each of them with different options. A few commonly used Tkinter widgets are given below:

Button

The button widget is used to display buttons on the application. It is declared as shown below:

but = Button (parent, options = value, ...)

In the syntax above, parent refers to the parent window and options are the commonly used options for the button widget.

Text

The text widget is used to display text on multiple lines. It is declared as shown below:

txt = Text(parent, width=num_characters, height=num_lines)

Here, parent refers to the parent window, and the width and height create a rectangle into which the user can type the text.

Frame

The frame widget is used as a container widget that organizes the other widgets. It is declared as shown below:

fr = Frame( parent, option, ...)

Here, options might include background color or size of the border, etc.

Other commonly used Tkinter widgets include:

  • Canvas: used to draw shapes (lines, polygons, rectangles, etc.).

  • Checkbutton: used to display a number of options as checkboxes.

  • Listbox: used to provide a list of options to a user.

  • Menu: used to provide various commands to the user.

For more details on Tkinter widgets, click here.

Create a GUI using Tkinter

You can create a simple GUI application using Tkinter by following the steps given below:

RELATED TAGS

python
tkinter

CONTRIBUTOR

Umme Ammara
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring