The Wayback Machine - https://web.archive.org/web/20240905182857/https://www.geeksforgeeks.org/python-todo-gui-application-using-tkinter/
Open In App

Python | ToDo GUI Application using Tkinter

Last Updated : 10 Jun, 2021
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Prerequisites : Introduction to tkinter 

Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. In this article, we will learn how to create a ToDo GUI application using Tkinter, with a step-by-step guide. 

To create a tkinter : 

  • Importing the module – tkinter
  • Create the main window (container)
  • Add any number of widgets to the main window.
  • Apply the event Trigger on the widgets.

The GUI would look like below:

Let’s create a GUI based simple ToDo application in which you can add and delete the Task.
 

Below is the implementation : 

Python3




# import all functions from the tkinter  
from tkinter import *
 
# import messagebox class from tkinter
from tkinter import messagebox
 
# global list is declare for storing all the task
tasks_list = []
 
# global variable is declare for counting the task
counter = 1
 
# Function for checking input error when
# empty input is given in task field
def inputError() :
     
    # check for enter task field is empty or not
    if enterTaskField.get() == "" :
         
        # show the error message
        messagebox.showerror("Input Error")
         
        return 0
     
    return 1
 
# Function for clearing the contents
# of task number text field
def clear_taskNumberField() :
     
    # clear the content of task number text field
    taskNumberField.delete(0.0, END)
 
# Function for clearing the contents
# of task entry field  
def clear_taskField() :
 
    # clear the content of task field entry box
    enterTaskField.delete(0, END)
     
# Function for inserting the contents
# from the task entry field to the text area
def insertTask():
 
    global counter
     
    # check for error
    value = inputError()
 
    # if error occur then return
    if value == 0 :
        return
 
    # get the task string concatenating
    # with new line character
    content = enterTaskField.get() + "\n"
 
    # store task in the list
    tasks_list.append(content)
 
    # insert content of task entry field to the text area
    # add task one by one in below one by one
    TextArea.insert('end -1 chars', "[ " + str(counter) + " ] " + content)
 
    # incremented
    counter += 1
 
    # function calling for deleting the content of task field
    clear_taskField()
 
# function for deleting the specified task
def delete() :
     
    global counter
     
    # handling the empty task error
    if len(tasks_list) == 0 :
        messagebox.showerror("No task")
        return
 
    # get the task number, which is required to delete
    number = taskNumberField.get(1.0, END)
 
    # checking for input error when
    # empty input in task number field
    if number == "\n" :
        messagebox.showerror("input error")
        return
     
    else :
        task_no = int(number)
 
    # function calling for deleting the
    # content of task number field
    clear_taskNumberField()
     
    # deleted specified task from the list
    tasks_list.pop(task_no - 1)
 
    # decremented
    counter -= 1
     
    # whole content of text area widget is deleted
    TextArea.delete(1.0, END)
 
    # rewriting the task after deleting one task at a time
    for i in range(len(tasks_list)) :
        TextArea.insert('end -1 chars', "[ " + str(i + 1) + " ] " + tasks_list[i])
     
 
# Driver code
if __name__ == "__main__" :
 
    # create a GUI window
    gui = Tk()
 
    # set the background colour of GUI window
    gui.configure(background = "light green")
 
    # set the title of GUI window
    gui.title("ToDo App")
 
    # set the configuration of GUI window
    gui.geometry("250x300")
 
    # create a label : Enter Your Task
    enterTask = Label(gui, text = "Enter Your Task", bg = "light green")
 
    # create a text entry box
    # for typing the task
    enterTaskField = Entry(gui)
 
    # create a Submit Button and place into the root window
    # when user press the button, the command or
    # function affiliated to that button is executed
    Submit = Button(gui, text = "Submit", fg = "Black", bg = "Red", command = insertTask)
 
    # create a text area for the root
    # with lunida 13 font
    # text area is for writing the content
    TextArea = Text(gui, height = 5, width = 25, font = "lucida 13")
 
    # create a label : Delete Task Number
    taskNumber = Label(gui, text = "Delete Task Number", bg = "blue")
                        
    taskNumberField = Text(gui, height = 1, width = 2, font = "lucida 13")
 
    # create a Delete Button and place into the root window
    # when user press the button, the command or
    # function affiliated to that button is executed .
    delete = Button(gui, text = "Delete", fg = "Black", bg = "Red", command = delete)
 
    # create a Exit Button and place into the root window
    # when user press the button, the command or
    # function affiliated to that button is executed .
    Exit = Button(gui, text = "Exit", fg = "Black", bg = "Red", command = exit)
 
    # grid method is used for placing
    # the widgets at respective positions
    # in table like structure.
    enterTask.grid(row = 0, column = 2)
 
    # ipadx attributed set the entry box horizontal size              
    enterTaskField.grid(row = 1, column = 2, ipadx = 50)
                        
    Submit.grid(row = 2, column = 2)
         
    # padx attributed provide x-axis margin
    # from the root window to the widget.
    TextArea.grid(row = 3, column = 2, padx = 10, sticky = W)
                        
    taskNumber.grid(row = 4, column = 2, pady = 5)
                        
    taskNumberField.grid(row = 5, column = 2)
 
    # pady attributed provide y-axis
    # margin from the widget.                 
    delete.grid(row = 6, column = 2, pady = 5)
                        
    Exit.grid(row = 7, column = 2)
 
    # start the GUI
    gui.mainloop()


Output: 



Previous Article
Next Article

Similar Reads

GUI chat application using Tkinter in Python
Chatbots are computer program that allows user to interact using input methods. The Application of chatbots is to interact with customers in big enterprises or companies and resolve their queries. Chatbots are mainly built for answering standard FAQs. The benefit of this type of system is that customer is no longer required to follow the same tradi
7 min read
Build GUI Application for Guess Indian State using Tkinter Python
In this article, you will learn to make a GUI game in Python, in which we will be shown a map of Indian states and an input prompt were in the prompt, the user has to enter a state name of India. If the user guessed it correctly, the name would hover over its location on the map. You can also see the score as the title of the input prompt window. M
8 min read
Create First GUI Application using Python-Tkinter
We are now stepping into making applications with graphical elements, we will learn how to make cool apps and focus more on its GUI(Graphical User Interface) using Tkinter. What is Tkinter?Tkinter is a Python Package for creating GUI applications. Python has a lot of GUI frameworks, but Tkinter is the only framework that’s built into the Python sta
12 min read
How to make a Todo List CLI application using Python ?
In this article, we see how to make a Command Line application todo list in python. Todo list is a basic application in which users can add items. It’s a list of tasks you need to complete or things that you want to do. In to-do, list tasks are organized in order of priority. One of the most important reasons you should use a to-do list is that it
7 min read
Todo List Application using MEAN Stack
The todo list is very important tool to manage our tasks in this hectic schedule. This article explores how to build to-do list application using the MEAN stack—MongoDB, Express.js, Angular, and Node.js. We’ll walk you through the process of setting up backends with Node.js and Express.js, integrating MongoDB for data storage efficiency, and using
10 min read
Todo List CLI application using Node.js
CLI is a very powerful tool for developers. We will be learning how to create a simple Todo List application for command line. We have seen TodoList as a beginner project in web development and android development but a CLI app is something we don't often hear about. Pre-requisites:A recent version of Node.js downloaded and installed.A text editor,
13 min read
Todo List Application using MERN
Todo list web application using MERN stack is a project that basically implements basic CRUD operation using MERN stack (MongoDB, Express JS, Node JS, React JS). The users can read, add, update, and delete their to-do list in the table using the web interface. The application gives a feature to the user to add a deadline to their task so that it us
9 min read
Python | Simple GUI calculator using Tkinter
Prerequisite: Tkinter Introduction, lambda function Python offers multiple options for developing a 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. Python with Tkinter outputs the fastest and easiest way to create GUI a
6 min read
Python | Distance-time GUI calculator using Tkinter
Prerequisites : Introduction to Tkinter | Using google distance matrix API Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter outputs the fastest and easiest wa
7 min read
Python | Create a GUI Marksheet using Tkinter
Create a python GUI mark sheet. Where credits of each subject are given, enter the grades obtained in each subject and click on Submit. The credits per subject, the total credits as well as the SGPA are displayed after being calculated automatically. Use Tkinter to create the GUI interface. Refer the below articles to get the idea about basics of t
8 min read
Python: Weight Conversion GUI using Tkinter
Prerequisites: Python GUI – tkinterPython offers multiple options for developing a 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. Python with Tkinter outputs the fastest and easiest way to create GUI applications. Crea
2 min read
Python | GUI Calendar using Tkinter
Prerequisites: Introduction to Tkinter Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. In this article, we will learn how to create a GUI Calendar application using
4 min read
Sentiment Detector GUI using Tkinter - Python
Prerequisites : Introduction to tkinter | Sentiment Analysis using Vader Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. In this article, we will learn how to creat
4 min read
Python - Morse Code Translator GUI using Tkinter
Prerequisites : Introduction to tkinter | Morse Code Translator Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. In this article, we will learn how to create a Morse
6 min read
Python - SpongeBob Mocking Text Generator GUI using Tkinter
Prerequisites : Introduction to tkinter | SpongeBob Mocking Text Generator Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. In this article, we will learn how to cre
4 min read
Python - Spell Corrector GUI using Tkinter
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. In this article, we will learn how to create a GUI Spell Corrector application using Tkinter, with a step-by-step gu
5 min read
Python - UwU text convertor GUI using Tkinter
Prerequisites :Introduction to tkinter | UwU text convertor Python offers multiple options for developing a 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. Python with Tkinter outputs the fastest and easiest way to crea
4 min read
GST Rate Finder GUI using Python-Tkinter
Prerequisites : Introduction to tkinter | Program to calculate GSTPython offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. In this article, we will learn how to create GST Rate Finder GUI application using Tkinter, with a step-by-step guide. To create a Tki
3 min read
Create Copy-Move GUI using Tkinter in Python
Everyone reading this post is well aware of the importance of Copying the file or moving the file from one specific location to another. In this post, we have tried to explain not only the program but added some exciting pieces of Interface. Up to now, many of you may get about what we are talking about. Yes, you are right, We are going to use "Tki
4 min read
Python - English (Latin) to Hindi (Devanagiri) text convertor GUI using Tkinter
Prerequisites : Introduction to tkinter | Text transliteration from English to Indian languages – Using indic-transliterationPython offers multiple options for developing a 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
4 min read
Standard GUI Unit Converter using Tkinter in Python
Prerequisites: Introduction to tkinter, Introduction to webbrowser In this article, we will learn how to create a standard converter using tkinter. Now we are going to create an introduction window that displays loading bar, welcome text, and user's social media profile links so that when he/she shares his code with some others, they can contact th
12 min read
Text to speech GUI convertor using Tkinter in Python
Prerequisite: Introduction to Tkinter Tkinter is the standard GUI library for Python. Python when combined with tkinter provides a fast and easy way to create GUI applications.By this library we can make a compelling choice for building GUI applications in Python, especially for applications where a modern sheen is unnecessary, and the top priority
3 min read
Python - Dynamic GUI Calculator using Tkinter module
Python provides many options for developing GUI like Kivy, PyQT, WxPython, and several others. Tkinter is the one that is shipped inbuilt with python which makes it the most commonly used out of all. Tkinter is easy, fast, and powerful. Beginners can easily learn to create a simple calculator using this article: Python | Simple GUI calculator using
3 min read
Tic Tac Toe game with GUI using tkinter in Python
Tic-tac-toe (American English), noughts and crosses (British English), or Xs and Os is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is the winner. tkinter Python library is used to create the GUI.
15+ min read
Scientific GUI Calculator using Tkinter in Python
Prerequisite: Python GUI – tkinter In this article, we are going to create GUI Scientific Calculator using Python. As you can see, calculating large numbers nowadays is difficult or time-consuming. We've created a simple Scientific Calculator GUI using Python that allows you to perform simple and complex calculations. To implement GUI we will use t
13 min read
Python - Compound Interest GUI Calculator using Tkinter
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the Python GUI Libraries, Tkinter is the most commonly used method. In this article, we will learn how to create a Compound Interest GUI Calculator application using Tkinter. Let’s create a GUI-based Compound Interest Calculator application. Importing the mod
6 min read
Rank Based Percentile Gui Calculator using Tkinter
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. In this article, we will learn how to create a Rank Based - Percentile Gui Calculator application using Tkinter, with a step-by-step guide. Prerequisites: Introduction to TkinterProgram to calculate t
7 min read
Create a GUI to check Domain Availability using Tkinter
There might be a case where a user wants to create a website and having certain ideas for the website's name but is struck on their availability. So let's develop a GUI that will check for domain availability. We will use the Python-whois module to get information about the website. It's able to extract data for all the popular TLDs (com, org, net,
2 min read
Create a GUI to Get Domain Information Using Tkinter
Prerequisites: Python GUI – tkinter Domain information is very important for every user. It contains information like Name, organization, State, city, Ip address, emails, server name, etc. In this article, we will write code for getting domain information and bind it with GUI Application. We will use the Python-whois module to get information about
2 min read
Ratio Calculator GUI using Tkinter
Prerequisite: Python GUI – tkinter Tkinter is the most commonly used library for developing GUI (Graphical User Interface) in Python. It is a standard Python interface to the Tk GUI toolkit shipped with Python. As Tk and Tkinter are available on most of the Unix platforms as well as on the Windows system, developing GUI applications with Tkinter be
3 min read