Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. GUI programming in python
  5. Tkinter Widgets

Tkinter Widgets

Python has a lot of GUI frameworks, but Tkinter is the only framework that’s built into the Python standard library.

GUI is nothing but a desktop app that provides you with an interface that helps you to interact with the computers and enriches your experience of giving a command (command-line input) to your code.

Tkinter is a GUI Library for Python that enables the user to create GUI application. It is a powerful Object-Oriented Language. With this we can make the front end of the app easily.

It is used to construct buttons, text box, labels, etc. It improves user interaction to make the application more understandable and user friendly.

Tkinter comes with the python installer and we don’t have to install it from anywhere else.

To create a tkinter app:

  1. Importing the module – tkinter
  2. Create the main window (container)
  3. Add any number of widgets to the main window
  4. Apply the event trigger on the widgets.

We can easily import it and use it in python.

syntax:-

import tkinter as tk 
      or
import tkinter

In this way we can import it in text editor in python and use it .

Tk provides the following widgets:

  • button
  • canvas
  • combo-box
  • frame
  • level
  • check-button
  • entry
  • level-frame
  • menu
  • list – box
  • menu button
  • message
  • tk_optoinMenu
  • progress-bar
  • radio button
  • scroll bar
  • separator
  • tree-view, and many more.
import tkinter 
m = tkinter.Tk() 
m.mainloop() 

This is all about tkinter in python.

Was this article helpful to you? Yes No

How can we help?