Window in tkinter is multiplying itself

Viewed 36

After clicking on command button remove window is appearing. After clicking second time 2 windows are appearing and it goes on. How to i make it so only 1 window will popup?

def remove():
    for widget in frame.winfo_children():
        widget.destroy()
    for app in apps:
        for f in os.listdir(app):
            os.remove(os.path.join(app, f))
        if len(os.listdir(app)) ==0:
            pup = tk.Tk()
            pup = tk.Label(pup, text="")
            pup.pack()
            showinfo("info", "folder cleared")
1 Answers

try to move

tk.Tk()

at the begin of the file, like

root = tk.Tk()
Related