Srivastava
3 min readFeb 4, 2021

--

Tkinter walkthrough

Bored giving inputs in terminalšŸ˜«!!! , try giving it a beautiful interface with Tkinter. Letā€™s do it. šŸ˜Ž

Design by Satyam Srivastava

What is a GUI
A graphical user interface (GUI) is a type of user interface through which users interact with electronic devices via visual indicator representations.

Graphical user interface (GUI), enables a person to communicate with a computer through the use of symbols, visual metaphors, and pointing devices. The objects change color, size, or visibility when the user interacts with them.

Python GUI

Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python

There are many graphical user interface (GUI) toolkits that you can use with the Python programming language like

  • Tkinter
  • wxPython
  • PyQt
  • Kivy

Tkinter

Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit.

It has a variety of commonly used GUI elements(like buttons, menus, labels, entry areas, etc) which are used to build the graphical interface, these elements are called Widgets. Widgets are eventful python objects that have a representation in the browser, often as a control like a slider, textbox, and many more.

Have look here, to know more about widgets .

So lets beginā€¦šŸ˜Œ

Installing Tkinter

Tkinter comes with the Python installer. We just need to check td/tk and IDE while installing python in the system, or you can install it by running pip command,

pip install tkinter

Getting started with Tkinter.

Table of content.

  • importing modules
  • Tkinter window display
  • Added menubar option
  • Added image/icon
  • Setting frames
  • Adding buttons
  • Ending by mainloop

Letā€™s create a simple GUI Calculator

  1. Importing all the necessary modules needed for adding features.

2. Making TKINTER window .

3. Adding MENUBAR to our Calculator Gui .

calling the added functions for performing added tasks.

4. Adding Image to our GUI.

there are many ways to the add the image, but using ā€˜PhotoImageā€™ makes it more easy and shorter way to add .

5. Setting frames for our GUI, for grouping and organizing all the widgets. It can be understood like a container that contains the widgets. And, an ENTRY widgets for displaying the numbers.

6. Adding all the buttons.

Functions for the buttons ā€¦

7. Adding mainloop() at the endĀ . Means that execution of your Python commands halts there. OR in simple way, to show your tkinter window mainloop is used, otherwise nothing would show up. So, donā€™t forget to add it at the end.

Get the complete code here.šŸ˜Œ

Congratulations!!!šŸŽ‰šŸŽŠ You have finally made a simple calculator with GUIšŸ»Ā .

If this development work through was really helpful to you, then share your reviews in the comment and donā€™t forget to give it a clapšŸ‘.

--

--