I have written a gui code in python which calculate the age however when i run the code it shows the error of label command: application is destroyed. Furthermore it only show a screen with blue background colrs there are no labels or button visible. Also there are two screen being appeared
can't invoke "label" command: application has been destroyed
import tkinter import tkinter.messagebox main_window=tkinter.Tk()
class My_Age_Calculator: def init(self): self.main_window= tkinter.Tk() self.main_window.geometry('525x260') self.main_window.title('Age Calculator') self.main_window.configure(bg='light blue')
## Creating Labels
# 1.Date of Birth
DOB=tkinter.Label(main_window, text="Date Of Birth", bg='pink')
#2. Given Date:
given_date=tkinter.Label(main_window, text="Given Date", bg="pink")
# 3. Day
Day = tkinter.Label(main_window, text = "Day", bg = "light blue")
#4. Month
Month =tkinter.Label(main_window, text = "Month", bg = "light blue")
#5.Year
Year = tkinter.Label(main_window, text = "Year", bg = "light blue")
#6. Given Day
Given_Day =tkinter.Label(main_window, text = "Given Day", bg = "light blue")
#7. Given Month
Given_Month =tkinter.Label(main_window, text = "Given Month", bg = "light blue")
#8. Given Year
Given_Year =tkinter.Label(main_window, text = "Given Year", bg = "light blue")
#9. Resultant Year
Resultant_Year = tkinter.Label(main_window, text = "Year", bg = "light blue")
#10.Resultant_Month
Resultant_month =tkinter.Label(main_window, text = "Month", bg = "light blue")
#11.Resultant_Day
Resultant_day = tkinter.Label(main_window, text = "Day", bg = "light blue")
## Creating Resultant Age and Clear all button:
#1 Resultant Age:
Resultant_Age = tkinter.Button(main_window, text = "Resultant Age", fg = "Black", bg = "light green", command=Calculate_Age)
#2. Clear All:
Clear_All = tkinter.Button(main_window, text = "Clear All", fg = "Black", bg = "light green", command= Clear_All)
## Creating Entry box for entering the information
#1 Date of Birth
day_box =tkinter.Entry(main_window)
month_box = tkinter.Entry(main_window)
year_box =tkinter.Entry(main_window)
#2 Given Date
given_day_box = tkinter.Entry(main_window)
given_month_box= tkinter.Entry(main_window)
given_year_box = tkinter.Entry(main_window)
#3. Resultant Age
resultant_year_box = tkinter.Entry(main_window)
resultant_month_box =tkinter.Entry(main_window)
resultant_Day_box = tkinter.Entry(main_window)
## The widgets are placed in their position using grid method.
#1. Date Of Birth
DOB.grid(row = 0, column = 1)
Day.grid(row = 1, column = 0)
day_box.grid(row = 1, column = 1)
Month.grid(row = 2, column = 0)
month_box.grid(row = 2, column = 1)
Year.grid(row = 3, column = 0)
year_box.grid(row = 3, column = 1)
#2. Given Date
given_date.grid(row = 0, column = 4)
Given_Day.grid(row = 1, column = 3)
given_day_box.grid(row = 1, column = 4)
Given_Month.grid(row = 2, column = 3)
given_month_box.grid(row = 2, column = 4)
Given_Year.grid(row = 3, column = 3)
given_year_box.grid(row = 3, column = 4)
#3. Resultant Age
Resultant_Age.grid(row = 4, column = 2)
Resultant_Year.grid(row = 5, column = 2)
resultant_year_box.grid(row = 6, column = 2)
Resultant_month.grid(row = 7, column = 2)
resultant_month_box.grid(row = 8, column = 2)
Resultant_day.grid(row = 9, column = 2)
resultant_Day_box.grid(row = 10, column = 2)
Clear_All.grid(row = 12, column = 2)
main_window.mainloop() agecal_1=My_Age_Calculator()
Please help me in solving these errors