_tkinter.TclError: can't invoke "button" command: application has been destroyed

Question:

You cant see the button

It wont work this is the code:
P.S. i put ? for personal stuff

sito = tk.Tk()
sito.geometry("800x500")
sito.title("???")
label = tk.Label(sito, text="???", font=('Arial', 18))
label.pack()
sito.mainloop()


def new_banana():
    sito1 = tk.Tk()
    sito1.geometry("800x500")
    sito1.title("???")
    label1 = tk.Label(sito1, text="???", font=('Arial', 18))
    label1.pack()
    sito1.mainloop()


Button1 = Button(sito, text="???", command=new_banana)
Button1.pack()

Asked By: Gigetto Lai

||

Answers:

#Try putting mainloop at the bottom?

    sito = tk.Tk()
    sito.geometry("800x500")
    sito.title("???")
    label = tk.Label(sito, text="???", font=('Arial', 18))
    label.pack()
    
    
    
    def new_banana():
        sito1 = tk.Tk()
        sito1.geometry("800x500")
        sito1.title("???")
        label1 = tk.Label(sito1, text="???", font=('Arial', 18))
        label1.pack()
        sito1.mainloop()
    
    
    Button1 = Button(sito, text="???", command=new_banana)
    Button1.pack()
    
    sito.mainloop()

#let me know if this worked

Answered By: zonellobster

I put mainloop at the bottom and now it works

Answered By: Gigetto Lai
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.