Clear the window in tkinter
I made a tkinter window in python with some widgets like so:
def createWidgets(self):
self.grid(padx=25, pady=25)
self.start = Button(self)
self.start["text"] = "Start"
开发者_如何学Go self.start["width"] = "15"
self.start["height"] = "1"
self.start["command"] = self.start_g
self.start.grid(row=0, column=1, pady=5, sticky=N)
The problem is, I want to remove a widget, so I could add something else to this window. I tried remove() grid_forget() and I can get rid of the widget. Is there any way to remove a widget or wipe the window?
You can call grid_forget()
on your widget to permanently remove it.
e.g
self.start.grid_forget()
If you wanted to clear the whole window then you could do the same on your main frame
.
精彩评论