Age Finder using Python Tkinter

Age Finder Using Python

Hello coders we create this project with Python Tkinter 

  •   In this project we create age finder programm

Libraries used-

  >>Tkinter(for GUI)

  >>Time(for date)

Step to create GUI-

  • Install Tkinter using pip install
  • Import Tkinter
  • Create the main window
  • Import png button

Algorithm-

  • Create window and entry box for Date Entry .
  • Create Text box for output
  •  Import png over button.
  • Create button and add command    

Source code-

  

#importing Library---------------------------------------------------------------------------------
from tkinter import*
import time

#defining Function---------------------------------------------------------------------------------
def Finder():
    Result.delete(0.0,"end")
    b=time.strftime("%d%m%Y")
    b_day=(int(b[:2]))
    b_month=(int(b[2:4]))
    b_year=(int(b[4:8]))
   # print(b_year)
    a=E1.get()
    a_day=(int(a[:2]))
    a_month=(int(a[3:5]))
    a_year=(int(a[6:10]))
    #print(a_year)

    if((b_day>=a_day) and (b_month>=a_month)):
        day=b_day - a_day
        month=b_month - a_month
        year=b_year - a_year
        Result.insert(0.0,"Years: "+str(year)+"\nMonths: "+str(month)+"\nDays: "+str(day))
       
    elif((b_day>=a_day) and (b_month+12>=a_month)):
        day=b_day - a_day
        month=b_month+12 - a_month
        year=b_year-1 - a_year
        Result.insert(0.0,"Years: "+str(year)+"\nMonths: "+str(month)+"\nDays: "+str(day))
        
    elif(b_day+30>=a_day) and (b_month-1>=a_month):
        day=b_day+30 - a_day
        month=b_month-1 - a_month
        year=b_year - a_year
        Result.insert(0.0,"Years: "+str(year)+"\nMonths: "+str(month)+"\nDays: "+str(day))
        
    elif(b_day+30>=a_day) and (b_month-1+12>=a_month):
        day=b_day+30 - a_day
        month=b_month-1+12 - a_month
        year=b_year-1 - a_year
        Result.insert(0.0,"Years: "+str(year)+"\nMonths: "+str(month)+"\nDays: "+str(day))
        
    else:
        Result.insert(0.0,"Invalid")
        

#creating WIndow---------------------------------------------------------------------------------
dob=Tk()
dob.title("Age Finder")
dob.config(bg="#CDB79E")
dob.minsize(350,315)
dob.maxsize(350,315)

#importing Imange--------------------------------------------------------------------------------
img = PhotoImage(file='calculate.png')


#Creating Entry Box------------------------------------------------------------------------------
E1=Entry(dob,font=("Time New Roman",16,"bold"),bd=1)
E1.place(x=1,y=1,width=230,height=42)
E1.insert(0,"Enter Date of birth")

def click(event):
    if E1.get()=="Enter Date of birth":
        E1.delete(0,END)
        E1.insert(0,'')

E1.bind('<FocusIn>',click)

Result=Text(dob,font=("Time New Roman",20,"bold"),bd=5,height=7,width=23,bg="#7AC5CD")
Result.place(x=1,y=60)

#Creating Button---------------------------------------------------------------------------------
b1 = Button(dob,image=img,borderwidth=0,command=Finder)
b1.place(x=230,y=1)



dob.mainloop()


#================================================================================================

OutPut:

Age Finder using Python Tkinter
Age Finder using Python Tkinter

Write a comment