Does anybody know how to clear all widgets; labels, buttons, etc. from a tkinter frame so that new ones may be put in their place? I've tried self.destroy() but that makes the frame unreachable, and self.grid_forget() followed by, "and without" self.grid() neither of these work, at least not as expected. any suggestions?
JoshuaBurleson
23
Posting Whiz
Recommended Answers
Jump to PostYou can pack them all into a Frame and destroy the Frame.
try: import Tkinter as tk ## Python 2.x except ImportError: import tkinter as tk ## Python 3.x class DestroyTest(): def __init__(self, top): self.top=top self.top.geometry("+10+10") self.frame=tk.Frame(self.top) self.frame.grid() test_label=tk.Label(self.frame, text="Label") test_label.grid(row=1, column=0) destroy_button=tk.Button(self.frame, text="Destroy Frame", \ command=self.destroy) …
All 3 Replies
nezachem
616
Practically a Posting Shark
woooee
814
Nearly a Posting Maven
JoshuaBurleson
commented:
PERFECT!
+4
JoshuaBurleson
23
Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.