Coders Packet

Modern Loan Calculator App using Python Tkinter

By Kaushik karthikeyan K

This Project is to develop a Loan Calculator app using Tkinter(GUI application) in Python Language. This application will calculate the Total loan amount for you.

Introduction to Tkinter Module:

Python offers many options for Graphical User Interface. Tkinter is the most popular one Since Python with Tkinter outputs the easiest and efficient way to create GUI applications.

 

Requirements:

Python Any Versions

Tkinter Module

 

Coding:

from tkinter import *           

class LoanCalculator:
    def __init__(self):   
        window = Tk() 
        window.title("Modern Loan Calculator") 
        window.configure(background = "gold")  

       
        Label(window, font='Helvetica 12 bold',text="Annual Interest Rate").grid(row=1,column=1, sticky=W)
        Label(window, font='Helvetica 12 bold',text="Number of Years").grid(row=2,column=1, sticky=W)
        Label(window, font='Helvetica 12 bold',text="Loan Amount").grid(row=3,column=1, sticky=W)
        Label(window, font='Helvetica 12 bold', text="Monthly Payment").grid(row=4,column=1, sticky=W)
        Label(window, font='Helvetica 12 bold',text="Total Payment").grid(row=5,column=1, sticky=W)


        self.annualInterestRateVar = StringVar()
        Entry(window, textvariable=self.annualInterestRateVar,justify=RIGHT).grid(row=1, column=2)

        self.numberofYearsVar = StringVar()
        Entry(window, textvariable=self.numberofYearsVar,justify=RIGHT).grid(row=2, column=2)

        self.loanAmountVar = StringVar()
        Entry(window, textvariable=self.loanAmountVar,justify=RIGHT).grid(row=3, column=2)

        self.monthlyPaymentVar = StringVar()
        lblMonthlyPayment= Label(window,font='Helvetica 12 bold',bg ="light green", textvariable=self.monthlyPaymentVar).grid(row=4,column=2, sticky=E)

        self.totalPaymentVar = StringVar()
        lblTotalPayment= Label(window,font='Helvetica 12 bold',bg ="light green", textvariable=self.totalPaymentVar).grid(row=5,column=2, sticky=E)


        btComputePayment = Button(window, text="Compute Payment",bg="red",fg="white",font='Helvetica 14 bold', command=self.computePayment).grid(row=6, column=2, sticky=E)
        btClear = Button(window, text="Clear",bg="blue",fg="white",font='Helvetica 14 bold', command=self.delete_all).grid(row=6, column=8, padx=20,pady=20 ,sticky=E)

        window.mainloop()  


    def computePayment(self):
        monthlyPayment = self.getMonthlyPayment(
            float(self.loanAmountVar.get()),
            float(self.annualInterestRateVar.get())  / 1200 ,
            int(self.numberofYearsVar.get()))


        self.monthlyPaymentVar.set(format(monthlyPayment, '10.2f'))
        totalPayment = float(self.monthlyPaymentVar.get()) * 12 \
         * int(self.numberofYearsVar.get())

        self.totalPaymentVar.set(format(totalPayment, '10.2f'))


    def getMonthlyPayment(self,loanAmount,monthlyInterestRate,numberofYears):
        monthlyPayment = loanAmount * monthlyInterestRate / (1-1/(1 + monthlyInterestRate)** (numberofYears * 12 ))
        return monthlyPayment   


    def delete_all(self) :
        self.monthlyPaymentVar.set("")
        self.loanAmountVar.set("")
        self.annualInterestRateVar.set("")
        self.numberofYearsVar.set("")
        self.totalPaymentVar.set("")





LoanCalculator()

 

Output:

output

 

Conclusion:

     From the Above project, we learnt some modules in Tkinter and how to calculate Loan amount and combine these two we create an application.

                                                                                                             

 

Download project

Reviews Report

Submitted by Kaushik karthikeyan K (kousikrish)

Download packets of source code on Coders Packet