×

Compound Interest GUI Calculator 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.

Advantages of GUI:

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.

Disadvantages of GUI:

Due to the numerous menus, some tasks may take a while to complete. The Help file must be used to search for hidden commands. Applications with a GUI require more RAM to operate. Compared to different interface types, it consumes more processing power.

Tkinter:

The standard Python technique for building Graphical User Interfaces (GUIs) is Tkinter, which is included in all popular Python distributions. The only framework included in the Python standard library is this one. On top of Tk, this Python framework serves as a thin object-oriented layer that provides access to the Tk toolkit. The Tk toolkit is a cross-platform set of "graphical control elements," also called widgets, used to build application interfaces. This framework gives Python users a quick and easy way to build GUI elements with the Tk toolkit's widgets. In a Python application, Tk widgets can be used to create buttons, menus, data fields, etc.

Once created, these graphic elements can be connected to or work with other widgets, features, functionality, processes, or data.

Tkinter bridges the gap between Python's execution model and Tcl's, built around cooperative multitasking. Like Python, Tcl is an interpreted dynamic programming language. Although it is an overall programming language that can be used independently, it is most frequently used in C programs as a scripting motor or as an interaction with the Tk toolbox. The Tcl library has a C interface that enables users to add custom Tcl or C commands, run Tcl commands and scripts, and manage one or more Tcl interpreter instances. Each interpreter has a queue for events that can be used to send and process events.

Syntax:

from tkinter import *
from tkinter import ttk

Advantages of Tkinter:

This promotes flexibility in handling GUI incidents, which makes the code base run more smoothly. Qt is more than just a framework; it uses a variety of native platform APIs for networking, database development, and other uses. Through a unique API, it gives them direct access.

Disadvantages of Tkinter:

Tkinter doesn't have any advanced widgets. There isn't a tool like Qt Designer for Tkinter in it. Its user interface is unreliable. Tkinter can be challenging to debug at times. It's not entirely in Python.

Compound Interest:

The yearly interest rate is raised to the number of composite periods minus one, and the initial original investment is multiplied by both these factors. The resulting value is then deducted from the loan's total initial amount.

Different options are available for creating a GUI or graphical user interface using a programming language like Python. Tkinter is the approach to the GUI that is most frequently used. In the following tutorial, we'll learn how to use Python’s Tkinter package to make a straightforward GUI calculator for compound interest. When interest is paid, that has been compounded at regular intervals on both the principal and the interest, known as compound interest. The accumulated Interest is combined with the current principal amount at regular intervals, and the Interest is then projected for the new principal. The initial principal and the interest already accrued make up the new principal.

CODE:

# import all classes/functions from the tkinter
from tkinter import *
 
# Function for clearing the 
# contents of all entry boxes  
def clear_all() :
 
    # whole content of entry boxes is deleted
    principle_field.delete(0, END)  
    rate_field.delete(0, END)
    time_field.delete(0, END)
    compound_field.delete(0, END)
   
    # set focus on the principle_field entry box 
    principle_field.focus_set()
# Function to find compound interest 
def calculate_ci():
 
    # get content from the entry box
    principle = int(principle_field.get())
     
    rate = float(rate_field.get())
 
    time = int(time_field.get())
     
    # Calculates compound interest 
    CI = principle * (pow((1 + rate / 100), time))
 
    # insert method inserting the 
    # value in the text entry box.
    compound_field.insert(10, CI)
# Driver code
if __name__ == "__main__" :
   
    # Create a GUI window
    root = Tk()
   
    # Set the background color of the GUI window
    root.configure(background = 'light green')
   
    # Set the configuration of the GUI window
    root.geometry("400x250")
   
    # set the name of the Tkinter GUI window
    root.title("Compound Interest Calculator") 
       
    # Create a Principle Amount: label
    label1 = Label(root, text = "Principle Amount(Rs) : ",
                   fg = 'black', bg = 'red')
   
    # Create a Rate: label
    label2 = Label(root, text = "Rate(%) : ",
                   fg = 'black', bg = 'red')
    # Create a Time: label
    label3 = Label(root, text = "Time(years) : ",
                   fg = 'black', bg = 'red')
 
    # Create a Compound Interest: label
    label4 = Label(root, text = "Compound Interest : ",
                   fg = 'black', bg = 'red')
 
    # grid method is used for placing 
    #the widgets in their proper positions in a structure resembling a table.
    # padx keyword argument used to set padding along the x-axis.
    # pady keyword argument used to set padding along the y-axis.
    label1.grid(row = 1, column = 0, padx = 10, pady = 10) 
    label2.grid(row = 2, column = 0, padx = 10, pady = 10) 
    label3.grid(row = 3, column = 0, padx = 10, pady = 10)
    label4.grid(row = 5, column = 0, padx = 10, pady = 10)
 
    # Create an entry box 
    # for filling in or typing the information.
    principle_field = Entry(root) 
    rate_field = Entry(root) 
    time_field = Entry(root)
    compound_field = Entry(root)
 
    # grid method is used for placing 
    # the widgets at respective positions 
    # in a table-likes structure.
     
    # padx keyword argument used to set padding along the x-axis.
    # pady keyword argument used to set padding along the y-axis.
    principle_field.grid(row = 1, column = 1, padx = 10, pady = 10) 
    rate_field.grid(row = 2, column = 1, padx = 10, pady = 10) 
    time_field.grid(row = 3, column = 1, padx = 10, pady = 10)
    compound_field.grid(row = 5, column = 1, padx = 10, pady = 10)
 
    # Create a Submit Button and attached 
    # to calculate_ci function 
    button1 = Button(root, text = "Submit", bg = "red", 
                     fg = "black", command = calculate_ci)
   
    # Create a Clear Button and attached 
    # to clear_all function 
    button2 = Button(root, text = "Clear", bg = "red", 
                     fg = "black", command = clear_all)
   
    button1.grid(row = 4, column = 1, pady = 10)
    button2.grid(row = 6, column = 1, pady = 10)
 
    # Start the GUI 
    root.mainloop()

OUTPUT:

Compound Interest GUI Calculator using Tkinter in Python

Related Topics

Python Validator

Validator  The validator is a library available in the python programming language. The library in python consists of all the related modules which can be imported to perform the required operation....

3 minutes read.

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

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

How to Iterate a List in Python

As we know, a List is one of the four unique data structures available in Python; in this article, we will deep dive into understanding iterating through a list and...

3 minutes read.

Best resources to learn Numpy and Pandas in python

In this tutorial, we will discuss the different resources where we can learn about NumPy and Pandas libraries of Python in a more efficient way. NumPy NumPy, a Python library used for...

4 minutes read.

Captcha Code in Python with Example

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

6 minutes read.

Reverse a sentence In Python

Introduction The built-in reverse() function is not supported by the Python string library. As we know, a Python string is defined as a set of Unicode characters and Python provides various...

4 minutes read.

Python program to find the GCD or HCF

Python program to find the GCD or HCF The largest positive integer that perfectly divides the two numbers is the HCF (Highest Common Factor) or GCD (Greatest Common Deviser). For example,...

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

Python Super function

The super function is used to access and call the methods or functions involved in the parent class during Inheritance. What is Inheritance? The process where the parent class inherits some of...

3 minutes read.

Confusion Matrix Visualization Python

The confusion matrix is a two-dimensional array that compares the anticipated and actual category labels. These are the True Positive, True Negative, False Positive, and False Negative classification categories for...

4 minutes read.

Inheritance in Python

Inheritance in Python Object-Oriented Programming provides reusable patterns to the code for restricting the redundancy in development projects. One of the basic principles of Object-Oriented Programming that helps achieve recyclable code...

8 minutes read.

How to Convert A List into String In Python?

How to Convert A List into String In Python? List is a data structure in Python that can hold values of different data types. The values are enclosed in square brackets...

3 minutes read.

Standard GUI Unit Converter using PyQt5 in Python

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

6 minutes read.

PyDev with Python IDE

What is IDE? Integrated Development Environment is the abbreviation of IDE. It is a coding tool that automates code editing, finding errors and testing. IDE combines all the developer tools into...

3 minutes read.

Python program to count the number of a substring in a string

Python program to count the number of a substring in a string A part of the string is called a substring. This article explains the Python program to find how many...

1 minute read.

Pltpcolor in Python

Python: 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 is said...

3 minutes read.

Python Filter List

To filter a list, we use filter () method function. The filter () will test every element true or not in the sequence. Syntax: Filter(function, sequence) Parameters: Function: Function that check and verifies if...

2 minutes read.

How to print in same line in python

How to Print in the Same Line in Python To print in Python, we use the print () function and the syntax of print () goes like this: print (values, sep =...

3 minutes read.

Tensorflow Angular in Python

TensorFlow is an open-source, Python-compatible toolkit for numerical computation that accelerates and simplifies the creation of neural networks and machine learning algorithms. They make the interesting notion that models can be...

6 minutes read.