×

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

Python Slice from Last Occurrence of K

Introduction We already know that in Python, cutting produces a sub-string out of a string. The variables start, stop, and step are used to set the slicing range. When dealing on...

3 minutes read.

How to Open a file in python with Path

In this tutorial, we will see rather than the traditional way of opening a file by locating or navigating it from our desktops; we will learn how to open the...

2 minutes read.

Fsolve in Python

Python Programming Language Python programming language is one of the most used programming languages, as it is used widely in the field of software and data analysis, web development, etc. It...

3 minutes read.

Python Set issubset() method

Python Set issubset() method The set.issubset() method in Python returns True if all items in the set exists in the specified set, otherwise it returns False. Syntax set.issubset(set1) Parameter set- This parameter represents the set to check whether...

2 minutes read.

How to build an Auto Clicker using Python?

What is an Auto Clicker? An Auto Clicker is software that is used for automating the click of a mouse on any particular element on the computer screen and controlling the...

8 minutes read.

Python Identifiers

Identifiers in Python User-defined names are identifiers in Python that are used to name variables, functions, classes, modules, and other things. You can create Python identifiers using these rules: As an identifier...

4 minutes read.

Standard Scalar in Python

Python is a vast and open-source language that contains many libraries, modules, and functions. These functions in python are reusable codes where we don’t need to type the whole code...

4 minutes read.

Salary of Python Developers in India

In this tutorial, we will understand who python developers are and what is their salary when they work in India. Python Developers Python Developers are the people who are involved in designing...

4 minutes read.

Python elif

Python elif The elif statement is used to check multiple conditions and execute the specific block of statements depending upon the true condition among them. Syntax if expression1: statement elif expression2: statement elif expression3: statement else: statement The elif statement can be optional...

3 minutes read.

Poolmanager in Python

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....

4 minutes read.

Magento 2 Site optimization

Magento 2 Site optimization Magento 2 is a CMS, commonly referred to as Intensive efficiency. Improving the speed and reliability of your Magento 2 app helps clients to achieve a better user experience while...

2 minutes read.

What is Python compiler GDB?

The source code of one programming language is converted into machine code, bytecode, or another programming language by a compiler, a specialised software. A compiler is a tool that converts high-level...

3 minutes read.

Python Variables

Variables are one of the most important terms we should be familiar with if we want to be good programmers. In simpler words, we use variables to store a value....

4 minutes read.

What is Python online compiler?

The compiler is a program that is used to scan an entire high-level program (source code) and it translates the scanned program into machine code. Compilers convert .py source code into...

5 minutes read.

Python Variables, Constants and Literals

Python is today's most valuable, easy-to-implement and sought-out programming language. Nowadays, developers want to focus on implementing the program rather than spending time with complex programs. So, for this reason,...

17 minutes read.

Python Modulo

For basic calculations, Python provides operators. Python supports a broad range of Arithmetic Operators to do arithmetic, as given below: +Addition*Multiplication-Subtraction/Division//Floor division**Exponentiation%Remainder/Modulus As you can see, one of these basic arithmetic operators...

8 minutes read.

Python sorted() function

Python sorted() function The sorted() function returns a sorted list of the specified iterable object. Syntax sorted(iterable, *, key=None, reverse=False) Parameter iterable: It is a required parameter that represents the sequence to sort, list, dictionary, tuple etc. key:...

1 minute read.

Python whois

What is whois? Whois is a protocol used to identify the owner of the registered domain name. It is a querying database that is used to record the registered users. WHOIS is...

4 minutes read.

Python exe() function

Python exe() function The exec() function in Python executes the specified Python code and accepts large blocks of code. It supports dynamic execution of Python code where the object must be either a string...

1 minute read.

Python List copy() method

Python List copy () method The list.copy () method returns a shallow copy of the list. Syntax list.copy() Parameter NA Return This function returns the copy for the given list. Example 1 # Python program explaining # the list.copy() method # passing the...

1 minute read.