0

when i run the program it has already deleted the widget btn. it returns frame1 with only the delete_button, which means it has already deleted btn prior to command.

when i removed the command Btn.destroy the program returns all the expected widgets.

import tkinter as tk


class run:
    def __init__(self, master):
        Btn = tk.Button(master, text="Btn1")
        Btn.pack()
        delete_button = tk.Button(master, text="start", command=Btn.destroy())
        delete_button.pack()


 master = tk.Tk()
 i = run(master)
 master.mainloop()
coder_not_found
  • 202
  • 2
  • 13
  • 1
    You call `Btn.destroy()` even before the `delete_button` is created. I think you were trying to do this: `delete_button = tk.Button(master, text="start", command=Btn.destroy)` – TheLizzard Feb 21 '21 at 11:21
  • 4
    TL;DR: You are calling the function with `()`, remove those. – Delrius Euphoria Feb 21 '21 at 11:21

0 Answers0