×

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

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

PyQt5:

PyQt5 is one of several solutions that Python offers for creating GUI applications. Cross-platform GUI toolkit PyQt5 is a collection of Python interfaces for Qt version 5. With the capabilities and convenience of use that this library offers, one can create an interactive computer program very quickly.  Front-end and Back-end make up a GUI application. In order to speed up development & allow more time to be spent on back-end tasks, PyQt5 has developed a tool called "QtDesigner" that allows one to drag and drop elements to create the front-end. Riverbank Computing is the company in charge of developing and maintaining PyQt. A most recent stable version is PyQt6. The PyQt main version's release cycle matches Qt's, as per the release history. The PyQt codebase is a complex system with both C++ and Py code at its core. It is therefore more difficult to create and download it from the sources than other Python libraries. Even more detailed installation instructions may be found in the instructions for the specific PyQt version we want to utilise. It comes with installation instructions for both the GPL and the paid versions. Before the window shows on the screen, a few essential concepts regarding the organisation of applications in the Qt world must be explained. Unless you're already familiar with event loops, you can proceed to the next part without risk. The cornerstone of all Qt programs is the QApplication class. For each application to function, there must be a single QApplication object. The primary loop in your programme that manages all interface with the GUI is housed in this object.

Installation:

pip install pyqt5
pip install pyqt5-tools

utilising a QT designer tool to create a signup form. To developed this skill, buttons, text boxes, etc., no coding is necessary! It is a drag-and-drop kind of setting. Therefore, using PyQt is easier than Tkinter.

Introduction to Compound Interest GUI calculator:

The interest that is given on both the capital and the interest that is compounded at regular intervals is known as compound interest. The accrued Interest is combined with the existing principal amount at regular intervals, and the Interest is then projected for the school president. The initial principal plus the interest that has already accrued make up the new principal.

Compound Interest = Interest on Principal + Compounded Interest at Standard Intervals 

Compound interest can be calculated in two stages. The starting amount of the main loan will be multiplied by one, along with the annualized rate rising to the amount of compounds periods minus one, to determine the final amount. The complete amount of the loan's initial principal will be deducted from the resultant value in the following step. We will receive compound interest from this, or CI.

By multiplying the real amount of the loan, asset, or principal by the annual interest rate, we may determine the annual compound interest. The compound interest for the second year will then be calculated by adding that sum to the principal and multiplying it by the rate of interest once more.

CODE:

from tkinter import *  
  
def reset():  
    principalField.delete(0, END)  
    rateField.delete(0, END)  
    numberField.delete(0, END)  
    timeField.delete(0, END)  
    resultField.delete(0, END)  
  
    principalField.focus_set()  
   
def compound_interest():  
    principal = float(principalField.get())  
    rate_of_interest = float(rateField.get())  
    number = float(numberField.get())  
    time = float(timeField.get())  
  
    amount = principal * pow((1 + (rate_of_interest / (100 * number))), number * time)  
    ci = amount - principal  
    resultField.insert(10, ci)  
  
if __name__ == "__main__":  
    guiWindow = Tk()  
    guiWindow.title("Compound Interest Calculator")  
    guiWindow.geometry("500x500+500+250")
    guiWindow.resizable(0, 0)   
    guiWindow.configure(bg = "#ffffff")    
    guiLabel = Label(guiWindow,text = "CALCULATE THE \nCOMPOUND INTEREST",  font = ("Arial", 20),fg = "#211600",bg = "#f0c33c")  
    guiLabel.place(x = 60,y = 10)  
    labelOne = Label(guiWindow,text = "Principal Amount (Rs.):",bg = "#f0c33c",fg = "#4a3200" )   
    labelTwo = Label(guiWindow,text = "Rate of Interest (%):",bg = "#f0c33c",fg = "#4a3200")   
    labelThree = Label(guiWindow,text = "Number of Times (n):",bg = "#f0c33c", fg = "#4a3200"  )  
    labelFour = Label(guiWindow,text = "Time Period (Years):",bg = "#f0c33c",fg = "#4a3200")   
    labelFive = Label(guiWindow,text = "Compound Interest (C.I.):",bg = "#f0c33c",fg = "#4a3200")  
  
    labelOne.place(x = 72, y = 120)  
    labelTwo.place(x = 72, y = 160)  
    labelThree.place(x = 72, y = 200)  
    labelFour.place(x = 72, y = 240)  
    labelFive.place(x = 72, y = 340)  
  
    principalField = Entry(guiWindow,bg = "#fcf9e8",fg = "#211600")  
    rateField = Entry(guiWindow,  bg = "#fcf9e8",fg = "#211600")  
    numberField = Entry(guiWindow, bg = "#fcf9e8",  fg = "#211600")  
    timeField = Entry( guiWindow, bg = "#fcf9e8",fg = "#211600")  
    resultField = Entry(guiWindow,bg = "#fcf9e8",fg = "#211600" )  
    principalField.place(x = 250, y = 120)  
    rateField.place(x = 250, y = 160)  
    numberField.place(x = 250, y = 200)  
    timeField.place(x = 250, y = 240)  
    resultField.place(x = 250, y = 340)  
    resultButton = Button(guiWindow, text = "CALCULATE", bg = "#135e96", fg= "#fcf9e8", command = compound_interest)  
    resetButton = Button(guiWindow, text = "RESET", bg = "#d63638", fg = "#fcf0f1", command = reset  )  
    resultButton.place(x = 280, y = 280)  
    resetButton.place(x = 300, y = 380)      
  
    guiWindow.mainloop()  

CODE EXPLANATION:

Import all required libraries next define the reset Function and also delete the entries in all entry fields. Set the focus to the entry field. Next define the function to calculate the compound interest further get the values from the entry fields also calculate the compound interest. Print the resultant value in result field. Next coming to the main function create a instance of the tk() class and define the title of GUI window ,define the geometry for the window also disabling the resizable option and set the background colour for the window. Heading on the window. Placing the label on the window next creating a principal amount label also create a rate of interest, number of times, time, compound Interest. Use place() method to place the above labels on the window. Next create a result button and reset button next run the window.

OUTPUT:

Compound Interest GUI Calculator using PyQt5 in Python

Related Topics

After Python, What Should I Learn

Python is a programming language used to create websites, software, and other projects. It is easy to code and easy to learn. After learning Python, there are many different directions...

4 minutes read.

Spyder (32-bit) - Free download

Spyder is a free and open-source scientific environment created by and for Python engineers, scientists, and data analysts. It is a robust scientific environment created in Python by and for...

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

What is a Script in Python

Have you ever heard that Python is a scripting language? Or when people address a Python program file as a script? Besides programming, script generally means "a written story for...

3 minutes read.

Conditional Expressions in Python

In Python conditional expression are sometimes referred to operator called as ternary operator. Not only Python supports ternary operator but many other programming languages supports it. Ternary operator are the...

2 minutes read.

Python Console

Console in Python is referred as the command line Interpreter- (CLI) and also knows as Shell and it functions as taking input from the human user and interpreting it through...

6 minutes read.

Python logging Module

Python logging Module Introduction By logging word we understand the tracking of the events which happens when we run some software. Logging process is very important part for developing software, debugging...

12 minutes read.

How to read data from com port in python

Comport, the I/O interface is known as a COM port that allows the connection for a serial device to a computer. COM ports are sometimes referred to as serial ports....

3 minutes read.

Python Command line Arguments

Python Command line Arguments The command-line argument is used to the change functionality of the program. It's an extra command the programmer can use while launching a program. These commands have many uses...

7 minutes read.

Python Setup guide and installation

Python Installation guide Step by Step Python is widely used high-level programming language. The first version of Python was launched in 1991. Since then, Python has been gaining popularity. It is considered as...

4 minutes read.

How to set font for Text in Python

As a tuple with the font family as the first component, a size in point as the second, and possibly a string with one or more of the style modifiers...

5 minutes read.

any() Keyword in python

“any” keyword in python This page contains all the information about any () Keyword in python, how it is used with lists, tuples, dictionaries, sets, and what its function is? Python...

3 minutes read.

Python String lower() method

Python String lower() method The string.lower() method in Python returns a string where all characters are lower case. Syntax string.lower() Parameter NA Return This method returns a string where all characters are lower case. Example 1 # Python...

1 minute read.

How to Make an App with Python

In this age of mobiles, rapid mobile application development has got a lot of traction. Moreover, app developers are high in demand because of the increase in digitization. Generally, Python is...

4 minutes read.

Python Set intersection() method

Python Set intersection() method The set.intersection() method in Python returns a new set with elements that are similar between two or more sets. Syntax set.intersection(set1, set2 ... etc) Parameter set1- This parameter represents the set to search for...

2 minutes read.

Python List remove() method

Python List remove() method The list.remove () method in Python removes the item at the specified position in the given list. Syntax list.remove(x) Parameter x: This parameter represents the element you want to remove and accepts any type...

1 minute read.

Python Set update() method

Python Set update() method The set.update() method in Python updates the current set, by adding items from another set. If an element is common in both the sets, only one appearance of this item...

1 minute read.

Python Random Module

The tutorial for the Python random module demonstrates how to produce pseudo-random integers in Python. Random Number Generator (RNG) The RNG (random number generator) generates a series of values with no discernible...

8 minutes read.

Write Dictionary to CSV in Python

Python is an Object-Oriented high-level language. Python has an English-like syntax, which is very easy to read and write codes. Python is an interpreted language which means that it uses...

4 minutes read.

Python exit commands

exit(), quit(), sys.exit(), os._exit() In this tutorial, we will study exit commands used in the Python programming language. Python is undoubtedly the choice of programmer and this is because of the in-built...

3 minutes read.