import tkinter as tk import random def my_func(): global counter_sec label["text"] = str(counter_sec) counter_sec+=1 w = random.randint(25,500) h = random.randint(25,500) wh = str(w)+"x"+str(h) window.geometry(wh) window.after(1000, my_func) counter_sec = 1 window = tk.Tk() label = tk.Label(text="0") label.pack() window.after(1000, my_func) window.mainloop()