from tkinter import *
import time
root = Tk()
root.title("Testing System")
root.geometry("900x600")
def main():
def tick():
time_str1= time.strftime("%H:%M:%S")
clock.config(text = "Current Time:\n" + time_str1)
clock.after(200, tick)
def date():
date_str1 = time.strftime("%A, %d %B %Y")
date2.config(text = date_str1)
date2.after(200, tick)
frame = Frame(root)
clock = Label(frame, font = ("times", 14, "bold"), bg = "light pink")
clock.place(x = 260, y = 60)
tick()
date2 = Label(frame, font = ("times", 13, "bold"))
date2.place(x = 40, y = 560)
date()
button1 = Button(frame,text = "Test", height = 2, width = 10, command = frame.destroy and menu)
button1.pack()
button1.place(x = 370, y = 150)
def menu():
button2 = Button(root,text = "It work?", height = 2, width = 10)
button2.pack()
button2.place(x = 370, y = 150)
main()
root.mainloop()
Why am I not able to display anything on it if I change to frame instead of root?
(e.g clock = Label (frame, ....) <-- Not able to display
(e.g clock = Label (root, ....) <-- Able to display
I am trying to clear the current window of main() so that it will load a fresh page for menu() when the button is selected.
Is there something wrong with my code? Any help is appreciated! Thank you.