Tkinter project: Simple Interest calculator
Introduction This project is a Simple Interest Calculator built using Python’s Tkinter library, which provides a graphical user interface (GUI) for users to input values and calculate simple interest. It's designed to help students and beginners understand basic GUI development and financial calculations in Python. Explanation Tools Used: Python — Programming language Tkinter — GUI toolkit included in Python's standard library Code Breakdown: 1. Importing & Creating the Window from tkinter import * b = Tk() b.minsize(800, 600) b.maxsize(800, 600) Tk() initializes the main window. minsize and maxsize fix the window size to 600x600 pixels. 2. Interest Function def Interest(): try: P = int(e1.get()) # Principal R = int(e2.get()) # Rate T = int(e3.get()) # Time I = (P * R * T) / 100 e4.delete(0, END) e4.insert(0, str(I)) except ValueError: e4.delete(0, END) e4.insert(0, "Invalid Input") Gets user input for Principal (P), Rate (R), and Time (T). Calculates Simple Interest using: [ \text{SI} = \frac{P \times R \times T}{100} ] Displays the result. Handles errors if input is not a number. 3. Labels and Input Fields l1 = Label(b, text="Principal($):", font=("arial",15)) l2 = Label(b, text="Rate(%):", font=("arial",15)) l3 = Label(b, text="Time(year):", font=("arial",15)) l4 = Label(b, text="Simple Interest", font=("arial",15)) e1 = Entry(b, font=("arial",15)) e2 = Entry(b, font=("arial",15)) e3 = Entry(b, font=("arial",15)) e4 = Entry(b, font=("arial",15)) Labels explain each input. Entry boxes allow user input. 4. Button b1 = Button(b, text="Check Simple Interest", font=("arial", 15), command=Interest) When clicked, the button calls the Interest() function. 5. Placing the Widgets l1.grid(row=1, column=1) l2.grid(row=2, column=1) l3.grid(row=3, column=1) l4.grid(row=5, column=1) e1.grid(row=1, column=2) e2.grid(row=2, column=2) e3.grid(row=3, column=2) e4.grid(row=5, column=2) b1.grid(row=4, column=1) Positions all widgets using grid layout. 6. Mainloop b.mainloop() Starts the GUI application loop so the window stays open. Full code from tkinter import * b = Tk() b.minsize(800, 600) b.maxsize(800, 600) def Interest(): try: P = int(e1.get()) R = int(e2.get()) T = int(e3.get()) I = (P * R * T)/100 e4.delete(0, END) e4.insert(0, str(I)) except ValueError: e4.delete(0, END) e4.insert(0, "Invalid Input") l1 = Label(b, text="Principal($):", font=("arial",15)) l1.grid(row=1, column=1) l2 = Label(b, text="Rate(%):", font=("arial",15)) l2.grid(row=2, column=1) l3 = Label(b, text="Time(year):", font=("arial",15)) l3.grid(row=3, column=1) l4 = Label(b, text="Simple Interest", font=("arial",15)) l4.grid(row=5, column=1) e1 = Entry(b, font=("arial",15)) e1.grid(row=1, column=2) e2 = Entry(b, font=("arial",15)) e2.grid(row=2, column=2) e3 = Entry(b, font=("arial",15)) e3.grid(row=3, column=2) e4 = Entry(b, font=("arial",15)) e4.grid(row=5, column=2) b1 = Button(b, text="Check Simple Interest", font=("arial", 15),command=Interest) b1.grid(row=4, column=1) b.mainloop() Conclusion This Simple Interest Calculator demonstrates how Python's Tkinter can be used to create interactive desktop apps. It's perfect for beginner coders, especially students, to understand: How functions and GUIs work together How to collect and validate user input How to perform basic mathematical operations in Python You can expand this project by adding: Compound Interest calculations Input validation for negative numbers A clear/reset button for fields

Introduction
This project is a Simple Interest Calculator built using Python’s Tkinter library, which provides a graphical user interface (GUI) for users to input values and calculate simple interest. It's designed to help students and beginners understand basic GUI development and financial calculations in Python.
Explanation
Tools Used:
- Python — Programming language
- Tkinter — GUI toolkit included in Python's standard library
Code Breakdown:
1. Importing & Creating the Window
from tkinter import *
b = Tk()
b.minsize(800, 600)
b.maxsize(800, 600)
-
Tk()
initializes the main window. -
minsize
andmaxsize
fix the window size to 600x600 pixels.
2. Interest Function
def Interest():
try:
P = int(e1.get()) # Principal
R = int(e2.get()) # Rate
T = int(e3.get()) # Time
I = (P * R * T) / 100
e4.delete(0, END)
e4.insert(0, str(I))
except ValueError:
e4.delete(0, END)
e4.insert(0, "Invalid Input")
- Gets user input for Principal (P), Rate (R), and Time (T).
- Calculates Simple Interest using: [ \text{SI} = \frac{P \times R \times T}{100} ]
- Displays the result.
- Handles errors if input is not a number.
3. Labels and Input Fields
l1 = Label(b, text="Principal($):", font=("arial",15))
l2 = Label(b, text="Rate(%):", font=("arial",15))
l3 = Label(b, text="Time(year):", font=("arial",15))
l4 = Label(b, text="Simple Interest", font=("arial",15))
e1 = Entry(b, font=("arial",15))
e2 = Entry(b, font=("arial",15))
e3 = Entry(b, font=("arial",15))
e4 = Entry(b, font=("arial",15))
- Labels explain each input.
- Entry boxes allow user input.
4. Button
b1 = Button(b, text="Check Simple Interest", font=("arial", 15), command=Interest)
- When clicked, the button calls the
Interest()
function.
5. Placing the Widgets
l1.grid(row=1, column=1)
l2.grid(row=2, column=1)
l3.grid(row=3, column=1)
l4.grid(row=5, column=1)
e1.grid(row=1, column=2)
e2.grid(row=2, column=2)
e3.grid(row=3, column=2)
e4.grid(row=5, column=2)
b1.grid(row=4, column=1)
- Positions all widgets using grid layout.
6. Mainloop
b.mainloop()
- Starts the GUI application loop so the window stays open.
Full code
from tkinter import *
b = Tk()
b.minsize(800, 600)
b.maxsize(800, 600)
def Interest():
try:
P = int(e1.get())
R = int(e2.get())
T = int(e3.get())
I = (P * R * T)/100
e4.delete(0, END)
e4.insert(0, str(I))
except ValueError:
e4.delete(0, END)
e4.insert(0, "Invalid Input")
l1 = Label(b, text="Principal($):", font=("arial",15))
l1.grid(row=1, column=1)
l2 = Label(b, text="Rate(%):", font=("arial",15))
l2.grid(row=2, column=1)
l3 = Label(b, text="Time(year):", font=("arial",15))
l3.grid(row=3, column=1)
l4 = Label(b, text="Simple Interest", font=("arial",15))
l4.grid(row=5, column=1)
e1 = Entry(b, font=("arial",15))
e1.grid(row=1, column=2)
e2 = Entry(b, font=("arial",15))
e2.grid(row=2, column=2)
e3 = Entry(b, font=("arial",15))
e3.grid(row=3, column=2)
e4 = Entry(b, font=("arial",15))
e4.grid(row=5, column=2)
b1 = Button(b, text="Check Simple Interest", font=("arial", 15),command=Interest)
b1.grid(row=4, column=1)
b.mainloop()
Conclusion
This Simple Interest Calculator demonstrates how Python's Tkinter can be used to create interactive desktop apps. It's perfect for beginner coders, especially students, to understand:
- How functions and GUIs work together
- How to collect and validate user input
- How to perform basic mathematical operations in Python
You can expand this project by adding:
- Compound Interest calculations
- Input validation for negative numbers
- A clear/reset button for fields