×

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

Python String capitalize() method

Python String capitalize() method The string.capitalize() method in Python returns a copy of the string with only its first character capitalized. Syntax string.capitalize() Parameter NA Return This function returns a string where the first character is upper...

1 minute read.

Python hex() function

Python hex() function The hex() function in Python  converts the specified number into a hexadecimal value. Syntax hex(x) Parameter x: The parameter represents an Integer value. Return This function Returns hexadecimal string. Example 1 # Python Program explaining # the hex() function print("The...

1 minute read.

Python Dictionary values() method

Python Dictionary values() method The dictionary.values() method in Python returns a view object that displays a list of all the values in the specified dictionary. Syntax dictionary.values() Parameter NA Return This method returns a view object. The...

1 minute read.

Python Interpreter

In this tutorial, we will go through the basic knowledge about what an interpreter is and how we use it in the python programming language. It is one of the...

3 minutes read.

Python IDE

What is an IDE?  An IDE or an Integrated Development Environment is a type of software where developers can develop many software’s and applications and run the programs inside it. An...

11 minutes read.

Reverse a Number 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.

Socket Programming in Python

Socket Programming in Python In this tutorial, we will discuss network programming using Python programming language. We will explore all basic concept of network with Python script. Network Services in Python Python has...

9 minutes read.

Operator Overloading in Python

In any programming language, + is an arithmetic operator; it adds two numbers to give the sum. Have you ever tried to concatenate two strings? Concatenating two strings is adding...

5 minutes read.

Python List insert() method

Python List insert() method The list.insert () method in Python inserts an item at the specified position. Syntax list.insert(i, x) Parameter i: This parameter represents a number specifying the position to insert the given value. x: This parameter signifies...

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

How to run a Program in Python

How to run a Program in Python Writing a program in Python is an easy task, beginners who are ready to kickstart their career in the world of programming can create...

3 minutes read.

Not supported between instances of str and int in python

In this article, you are going to learn why the type error occurs between instances of string and integer datatypes. Also, you will know what kind of error is the...

6 minutes read.

Python Glob

Methods for matching files that include particular patterns in accordance with UNIX shell-related expansion rules are referred to as "glob" methods. Similar methods for finding, locating, and searching for all of...

12 minutes read.

Best books for NLP with Python

NLP NLP – Natural language processing Computers were created to make the life of mankind easier. But computers cannot understand human language. Instead, they interact with numbers to perform the tasks allotted...

12 minutes read.

NSE Tools In Python

About NSE NSE (National Stock Exchange) of India Limited is the advanced stock exchange of India. It is located in Mumbai, Maharastra and It was organized in 1992. It was...

2 minutes read.

Excel Automation with Python

Data analysis is the upcoming technology in the IT sector; this data analysis can be performed easily with the help of data frames or by using excel sheets. The data...

4 minutes read.

Difference between Perl and Python

Control and presently utilized for a great many undertakings, including framework organization, web improvement, network programming, and GUI improvement, and the sky is the limit from there. About Perl? Perl is a...

4 minutes read.

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

4 minutes read.

Python String splitlines() method

Python String splitlines() method The string.splitlines() method in Python splits the specified string and returns a list of the lines in the string, breaking at line boundaries.  Syntax splitlines([keepends]) Parameter keepends(optional): This parameter specifies if...

1 minute read.

Python String center() method

Python String center() method The center() method will center align the string, using a specified character (space is default) as the fill character. Syntax string.center(width[, fillchar]) Parameter width This parameter represents the length of the returned string. fillchar...

1 minute read.