Below is the script for the age calculator software!
from tkinter import *
import tkinter as tk
def solution():
currentyear = currententry.get()
birthyear= birthentry.get()
finalanswer = int(currentyear) - int(birthyear)
answer.delete(0.0, END)
answer.insert(END, "You are ")
answer.insert(END, finalanswer)
answer.insert(END, " years old!")
window = Tk()
window.geometry("800x500")
window.title("Age Calculator")
title = Label(window,font=('Consolas',17,'bold'), text = "Welcome to Age Calculator!",fg="black")
title.grid(row=1,column=3,padx=70,pady=30)
currentyear = Label(window,font=('Consolas',17,'bold'),text = "Enter Your Current Year: ",fg="black")
currentyear.place(relx=.03,rely=.20)
currententry = tk.Entry()
currententry.place(relx=.41,rely=.22)
birthyear = Label(window,font=('Consolas',17,'bold'), text = "Enter Your Birth Year: ", fg ="black")
birthyear.place(relx=.03, rely =.35)
birthentry = tk.Entry()
birthentry.place(relx=.39,rely=.36)
calculate = Button(window,text = "Get Answer", font =('Consolas',15,'bold'),command=solution)
calculate.place(relx=.24,rely=.44)
answer = Text(window, height=6,width=30,font=('Consolas'))
answer.place(relx=.13,rely=.75)
window.mainloop()
No comments:
Post a Comment