from tkinter import * def fr(w,h,b,x,y): Frame(r,width=w,height=h,bg=b).place(x=x,y=y) def lab(t,b,f,x,y): Label(r,text=t,bg=b,fg=f).place(x=x,y=y) r=Tk() def age(): fr(1000,2000,'grey',0,0) fr(600,350,'orange',50,150) fr(600,350,'yellow',50,550) fr(200,50,'pink',280,970) lab('DAY-1','pink','black',90,200) lab('MONTH-1','pink','black',260,200) lab('YEAR-1','pink','black',490,200) lab('DAY-2','orange','black',90,600) lab('MONTH-2','orange','black',260,600) lab('YEAR-2','orange','black',490,600) e1=Entry(r) e1.place(x=90,y=300,width=100) e2=Entry(r) e2.place(x=280,y=300,width=100) e3=Entry(r) e3.place(x=465,y=300,width=170) e4=Entry(r) e4.place(x=90,y=700,width=100) e5=Entry(r) e5.place(x=280,y=700,width=100) e6=Entry(r) e6.place(x=465,y=700,width=170) Label(r,text='Age Calculator',bg='cyan',fg='black').place(x=230,y=40) def Age(): d=int(e1.get()) m=int(e2.get()) y=int(e3.get()) da =int(e4.get()) mo=int(e5.get()) ye=int(e6.get()) y_a=y+1 y_b=ye-1 num=0 while y_a<=y_b: if y_a%4==0: num=num+366 y_a=y_a+1 else : num=num+365 y_a=y_a+1 if y!=ye: def ab(): if ye%4==0: if mo==1: return (da) elif mo==2: return (da+31) elif mo==3: return (da+60) elif mo==4: return (da+91) elif mo==5: return (da+121) elif mo==6: return (da+152) elif mo==7: return (da+182) elif mo==8: return (da+213) elif mo==9: return (da+244) elif mo==10: return (da+274) elif mo==11: return (da+305) elif mo==12: return (da+335) else : if mo==1: return (da) elif mo==2: return (da+31) elif mo==3: return (da+59) elif mo==4: return (da+90) elif mo==5: return (da+120) elif mo==6: return (da+151) elif mo==7: return (da+181) elif mo==8: return (da+212) elif mo==9: return (da+243) elif mo==10: return (da+273) elif mo==11: return (da+304) elif mo==12: return (da+334) def bc(): if y%4==0: if m==1: return (366-d) elif m==2: return (335-d) elif m==3: return (306-d) elif m==4: return (275-d) elif m==5: return (245-d) elif m==6: return (214-d) elif m==7: return (184-d) elif m==8: return (153-d) elif m==9: return (122-d) elif m==10: return (92-d) elif m==11: return (61-d) elif m==12: return (31-d) else : if m==1: return (365-d) elif m==2: return (334-d) elif m==3: return (306-d) elif m==4: return (275-d) elif m==5: return (245-d) elif m==6: return (214-d) elif m==7: return (184-d) elif m==8: return (153-d) elif m==9: return (122-d) elif m==10: return (92-d) elif m==11: return (61-d) elif m==12: return (31-d) abv=ab()+bc()+num O['text']=str(abv) else: def ab(): if ye%4==0: if mo==1: return (da) elif mo==2: return (da+31) elif mo==3: return (da+60) elif mo==4: return (da+91) elif mo==5: return (da+121) elif mo==6: return (da+152) elif mo==7: return (da+182) elif mo==8: return (da+213) elif mo==9: return (da+244) elif mo==10: return (da+274) elif mo==11: return (da+305) elif mo==12: return (da+335) else : if mo==1: return (da) elif mo==2: return (da+31) elif mo==3: return (da+59) elif mo==4: return (da+90) elif mo==5: return (da+120) elif mo==6: return (da+151) elif mo==7: return (da+181) elif mo==8: return (da+212) elif mo==9: return (da+243) elif mo==10: return (da+273) elif mo==11: return (da+304) elif mo==12: return (da+334) def bc(): if y%4==0: if m==1: return (d) elif m==2: return (d+31) elif m==3: return (d+60) elif m==4: return (d+91) elif m==5: return (d+121) elif m==6: return (d+152) elif m==7: return (d+182) elif m==8: return (d+213) elif m==9: return (d+244) elif m==10: return (d+274) elif m==11: return (d+305) elif m==12: return (d+335) else : if m==1: return (d) elif m==2: return (d+31) elif m==3: return (d+59) elif m==4: return (d+90) elif m==5: return (d+120) elif m==6: return (d+151) elif m==7: return (d+181) elif m==8: return (d+212) elif m==9: return (d+243) elif m==10: return (d+273) elif m==11: return (d+304) elif m==12: return (d+334) aav=ab()-bc() O['text']=str(aav) O=Label(r,bg='pink') O.place(x=300,y=970) Button(r,text='Compute',bg='orange',command=Age).place(x=260,y=1100) Button(r,text='BACK',bg='orange',command=r.quit).place(x=280,y=1250) age() r.mainloop()