What is Tkinter?

What is Tkinter?

Hello everyone, in this module we will discuss about What is Tkinter? You may hear about Tkinter. So the question arises that what is Tkinter and why it is necessary.

What is Tkinter
What is Tkinter

Python provides us various options to crate GUI(Graphical User interfaces), tkinter is one of them. In simple words we can define tkinter is:

  • Tkinter stands for ‘Tkinter Interface’
  • It is standard python library to interface with Tk GUI toolkit
  • Tkinter is written in python.
  • It is most widely used for developing python GUI Applications
  • Tkinter is an fast and easy way to developing interactive user interfaces
  • As it is provide interface with Tk GUI toolkit, so it support various widgets like entry, buttons etc.
  • In python 2.0 it was known as ‘Tkinter’, but in python 3.0 it renamed as ‘tkinter’
  • Now it consist with standard Linux, Microsoft Windows and Mac OS X installs of Python

To understand Tkinter deeply, first of all we need to understand about TCL.

What is Tcl/tk and how Tkinter Introduced?

TCL stands for True Command Language.It is general-purpose, high-level, interpreted, dynamic programming language. It is very easy and powerful language. Here are some important points about TCL:

  • It was first introduced in 1988 by John Ousterhout.
  • Like python it support multiple programming paradigms like Object Oriented Programming, Procedural Oriented Programming etc.
  • It is an cross platform language that allows to run TCL on wide variety of systems.
  • It is common application is embedded system, i.e. it can be run on other language independently.
  • Furthermore, it combine with Tk extension, this combination is known as Tcl/Tk
  • This combination allows us to build Graphical User Interfaces natively in TCL.
  • So now Tcl/Tk comes with installation of python i.e. known as Tkinter.

Why need Tkinter?

As we know that python is an server side language, which runs on command line. So sometimes the application developed in python, proves less interactive to the user. Because the application we develop in python runs on black screen or command line. So, to make them more interactive we needs an Graphical User Interface rather than Command Line Interface. Here is the way how the aystem layer interacts:

What is Tkinter
What is Tkinter : layers

As you can see in the image above, Tkinter has an interface with Python and Tcl/tk. Here is the detailed explanation of above image:

  • First of all here is an Hardware layer, which interfaces with OS.
  • Tcl/tk is responsible to actually creates multiple widgets like Entry box, button etc.
  • As we know that TCL is an another language, so to use it in python we need an interface.
  • This interface is Tkinter, which we can say that call to Tcl/tk and enable python application to add widgets.

How Tkinter works | Tkinter first window

To create an GUI with python, we need to do is:

  1. Call to Tkinter i.e. import tkinter library
  2. Create an Tkinter window
  3. Apply widgets on that window
  4. Apply events on the widgets to perform actions
  5. Call to infinite loop, which is responsible to show the main window.

Example

from tkinter import * #in python 2.0 its "Tkinter"

#Create Main Window
main_window = Tk()

#Add Title on Window
main_window.title("First Window")

#Add Widgets
Label(main_window,text="Welcome to First Window",fg='red',bg='yellow').pack()   

#Show main_window

Output

What is Tkinter
What is Tkinter

So it is all about today’s tutorial, to learn more widgets and geometry managers of Tkinter visit the link below:

pack()

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.