## Python 3 Tkinter Simple Arithmetic Calculator GUI Desktop App Full Project For Beginners

`app.py`

``````import tkinter as tk
from tkinter import *
root = tk.Tk()
root.geometry("170x230")
root.title("Calculator")
root.maxsize(170,230)
root.minsize(170,230)

#Entry Widgets to show calculations
inp = Entry(root,width=16,borderwidth=3,relief=RIDGE)

# <====================  Button Operation code starts here.. ==============>
def nine():
inp.insert("end","9")

def eight():
inp.insert("end","8")

def seven():
inp.insert("end","7")

def six():
inp.insert("end","6")

def five():
inp.insert("end","5")

def four():
inp.insert("end","4")

def three():
inp.insert("end","3")

def two():
inp.insert("end","2")

def one():
inp.insert("end","1")

def zero():
inp.insert("end","0")

def double_zero():
inp.insert("end","00")

def dot():
inp.insert("end",".")

def plus():
inp.insert("end","+")

def minus():
inp.insert("end","-")

def mul():
inp.insert("end","*")

def divide():
inp.insert("end","/")

def modulus():
inp.insert("end","%")

def result():

if inp.get() == "":
inp.insert("end","error")
elif inp.get()[0] == "0":
inp.delete(0,"end")
inp.insert("end","error")

else:
res = inp.get()
res = eval(res)
inp.insert("end"," = ")
inp.insert("end",res)

def clear():
inp.delete(0,"end")

# <============ end code ================>

# <============= Button Design Code starts here.. ==================>

clear = Button(root,text="C",width=2,command=clear,bg="red",fg="white",relief=RIDGE)

nine = Button(text="9",width=2,command=nine,borderwidth=3,relief=RIDGE)

eight = Button(text="8",width=2,command=eight,borderwidth=3,relief=RIDGE)

seven = Button(root,text="7",width=2,command=seven,borderwidth=3,relief=RIDGE)

plus = Button(root,text="+",width=2,command=plus,borderwidth=3,relief=RIDGE)

six = Button(text="6",width=2,command=six,borderwidth=3,relief=RIDGE)

five = Button(text="5",width=2,command=five,borderwidth=3,relief=RIDGE)

four = Button(root,text="4",width=2,command=four,borderwidth=3,relief=RIDGE)

minus = Button(root,text="-",width=2,command=minus,borderwidth=3,relief=RIDGE)

three = Button(text="3",width=2,command=three,borderwidth=3,relief=RIDGE)

two = Button(text="2",width=2,command=two,borderwidth=3,relief=RIDGE)

one = Button(root,text="1",width=2,command=one,borderwidth=3,relief=RIDGE)

multiply = Button(root,text="*",width=2,command=mul,borderwidth=3,relief=RIDGE)

zero = Button(text="0",width=2,command=zero,borderwidth=3,relief=RIDGE)

double_zero = Button(text="00",width=2,command=double_zero,borderwidth=3,relief=RIDGE)

dot = Button(root,text=".",width=2,command=dot,borderwidth=3,relief=RIDGE)