'Window' object has no attribute '_tclCommands' 'Window' object has no attribute '_tclCommands' tkinter tkinter

'Window' object has no attribute '_tclCommands'


You probably want to inherit from Frame because your class is missing some of the common methods a Tkinter widget has:

    self.grid()    self.create_widgets()    self.configure(background = background_color)

grid() and configure() have not yet been implemented in your class, right? So there lies your problem, you need to subclass a Tkinter widget class to have all those nice methods:

    class Window(Frame):


Idle is written with Tkinter I am told and so running Tkinter programs in Idle can cause problems, i.e. run it from the command line or another IDE. There are many problems with your program and it is easier to create a working program than to go over each error individually. The Effbot site is a good place to start learning Tkinter as it has simple examples for each widget http://effbot.org/tkinterbook/

class Window:    def __init__(self, master):        self.fr=Frame(master)        self.fr.grid()        self.create_widgets()        background_color = 'SlateGray'        text_background_color = 'DarkViolet'        self.fr.configure(background = background_color)        self.tl=Toplevel(master)        Button(self.tl, text = "Remove TopLevel",               command=self.clear_tl).grid(row = 1, column = 2)    def create_widgets(self):        self.button = Button(self.fr, text = "Clear Frame",                            command=self.clear_screen)        self.button.grid(row = 1, column = 1)    def clear_screen(self):        self.fr.grid_forget()    def clear_tl(self):        self.tl.destroy()  ## removes the windowroot=Tk()    ##root.configure(background = background_color)root.title("Guess Your Birthday")app = Window(root)root.mainloop()