×

To Do GUI Application using Tkinter in Python

GUI:

One of the most significant factors that increased the usability of computer and digital technologies for common, less tech-savvy users is likely the development and widespread adoption of GUIs. GUIs are intuitive enough that even relatively unskilled employees without programming experience can use them. Because they are always designed with the user in mind rather than being primarily machine-centered, they have become the standard in software application programming.

The user is provided with information using manipulable visual widgets that don't require command-line input. These interface components respond to the user's interactions per the pre-programmed script, assisting each user's action. Since many GUIs represent text and graphical elements in standard formats, it is possible for programs using the same GUI software to share data. As it is patched and developed, the same software application or os version may present distinct or marginally distinct GUIs. The appearance of an application may change depending on user needs or to enhance the user experience, even if the application's core functionality and functions remain unchanged, as was the case with the various Windows versions over time.

A graphical interface (GUI) is a user interface that lets users interact with electronic devices like computers and smartphones by using menus, icons, and other visual cues (graphics). In contrast to text-based interfaces, which only display data and commands as text, GUIs visualize information and related user controls. A cursor, trackball, stylus, or thumb on a touch screen are all pointing devices that can be used to communicate with GUI representations. The first text interface between a human and a computer operated using keyboard input and a prompt.

Commands were entered at the DOS prompt to ask for responses from a desktop. These commands' usage and the requirement for precise spelling led to an unwieldy and ineffective user interface.

Quick and easy access to any screen area allows for full-screen interaction. You merely click a button or an icon to invoke the necessary function. The general public now has access to a wide range of systems for daily use, regardless of experience or knowledge, thanks to the simplicity of GUIs. Additionally, Tkinter provides access to the widgets' geometric configuration, which can arrange the widgets in the parent windows.

CODE:

# import all functions from the tkinter  
from tkinter import *
from tkinter import messagebox
tasks_list = [] 
counter = 1
def inputError() :
    if enterTaskField.get() == "" :
        messagebox.showerror("Input Error")         
        return 0   
    return 1 
def clear_taskNumberField() :     
    taskNumberField.delete(0.0, END)
 def clear_taskField() : 
    enterTaskField.delete(0, END)     
def insertTask(): 
    global counter
    value = inputError() 
    if value == 0 :
        return
    content = enterTaskField.get() + "\n" 
    tasks_list.append(content) 
    TextArea.insert('end -1 chars', "[ " + str(counter) + " ] " + content) 
    counter += 1 
    clear_taskField() 
def delete() :     
    global counter     
    if len(tasks_list) == 0 :
        messagebox.showerror("No task")
        return
     number = taskNumberField.get(1.0, END)
    if number == "\n" :
        messagebox.showerror("input error")
        return     
    else :
        task_no = int(number) 
    clear_taskNumberField()     
    tasks_list.pop(task_no - 1) 
    counter -= 1     
    TextArea.delete(1.0, END) 
    for i in range(len(tasks_list)) :
        TextArea.insert('end -1 chars', "[ " + str(i + 1) + " ] " + tasks_list[i])     
if __name__ == "__main__" : 
    gui = Tk() 
    gui.configure(background = "light green") 
    gui.title("ToDo App") 
    gui.geometry("250x300")
    enterTask = Label(gui, text = "Enter Your Task", bg = "light green")
    enterTaskField = Entry(gui)
    Submit = Button(gui, text = "Submit", fg = "Black", bg = "Red", command = insertTask)
    TextArea = Text(gui, height = 5, width = 25, font = "lucida 13")
    taskNumber = Label(gui, text = "Delete Task Number", bg = "blue")                     
    taskNumberField = Text(gui, height = 1, width = 2, font = "lucida 13")   
    delete = Button(gui, text = "Delete", fg = "Black", bg = "Red", command = delete) 
    Exit = Button(gui, text = "Exit", fg = "Black", bg = "Red", command = exit)     
    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)          
    TextArea.grid(row = 3, column = 2, padx = 10, sticky = W)                        
    taskNumber.grid(row = 4, column = 2, pady = 5)                        
    taskNumberField.grid(row = 5, column = 2) 
    delete.grid(row = 6, column = 2, pady = 5)                        
    Exit.grid(row = 7, column = 2) 
    # start the GUI
    gui.mainloop()

OUTPUT:

To-Do GUI Application using Tkinter in Python

Related Topics

Looping through Data Frame in Python

Iterate over Rows and Columns in Pandas Dataframe This tutorial aims to make us understand what Pandas in Python are, what Data Frame in Python is and its significance, what are...

4 minutes read.

Nested Tuple in Python

If you are a Python learner, this page contains all the information that helps you know about nested tuple and how to access it in python. What is a Tuple? Multiple items...

4 minutes read.

Check Letter in a String Python

Checking a specific letter or a character in a given string or a string which is taken as an input from the user is possible in Python in broadly three...

3 minutes read.

Python Modules List

Python is like an ocean. If you have been working with Python, you might’ve already heard the word module. When we solve a problem in mathematics, there will be several...

3 minutes read.

CSV Module In Python

Introduction CSV stands for "comma separated values". It is the most common and simple file structure used for storing and arranging tabular data. for example; a spreadsheet or database. It stores...

5 minutes read.

Python Struct

Python Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster way....

3 minutes read.

Python Time Library

We will consider various functions given by the python module library with examples.This python time module helps to work on time in python to get the current time.Before going with...

4 minutes read.

Python Bitwise Operators

When used with variables and objects in an expression, operators are tokens that carry out calculations. The variables and items to which the computation is applied are known as operands....

5 minutes read.

Python Control Statements

Control statements are under the roof topic of loops and loops in python are defined as iteratively and repeatedly working on source code. Loop control statements are defined as they...

3 minutes read.

Python for Data Analysis

Data analysis uses various techniques to read, illustrate, manipulate and evaluate a particular data. You can have access to the data and keep the data updated regularly. You can append...

4 minutes read.

Python Program to find the length of a string

Python program to find the length of a string A string in Python is a set of Unicode characters. It can't be changed once it's been declared. The number of characters...

2 minutes read.

Image to Text in python

Processing out information from an image is a very big task in all the fields of work such as in development and business sector. The process of converting an electronical...

3 minutes read.

Palindrome program in Python

Palindrome program in python A number or string is said to be a palindrome if we invert the number or string and the string or number remains the same as the...

3 minutes read.

Python abs() function

Python abs() function The abs() function returns the absolute value of a number. Syntax abs(x) Parameter x: The parameter ‘x’ can be an integer value, a floating point number or a complex number. Return This function returns...

1 minute read.

Read JSON File in Python

JSON refers to the JavaScript Object Notation. It is a Data format used for representing structured data and it is used to transfer and store data. In JSON format, the...

5 minutes read.

__init__ in python

Every programmer will enclose to object-oriented programming (OOP) these days. As we know, that python is the latest and most modern programming language; python supports to implementation of object-oriented philosophy....

5 minutes read.

Image to NumPy Arrays in Python

Image is a simple process of working model confined to machine learning, Python works with the image in the data format of width and height i.e. Images are excelled into...

3 minutes read.

Is Python Object Oriented Programming language

In this tutorial, we will see whether python also belongs to an object-oriented programming language like several others. We will also see the advantages of using OOPs. Further, we will...

4 minutes read.

List Comprehension in Python

Sometimes we need new lists that are completely based on previously existing lists, so to perform this operation successfully, some of the programming languages come with a syntactic construct known...

5 minutes read.

How to uninstall python

To un-install Python, we need to follow different procedures in different operating systems. In this article, we will discuss the un-installation process of Python in Windows, Mac, and Linux operating...

4 minutes read.