Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: removing a TKinter frame

Tags:

python

tkinter

I want to remove a frame from my interface when a specific button is clicked.

This is the invoked callback function

def removeMyself(self):
    del self

However, it doesn't remove itself. I'm probably just deleting the object in python without updating the interface ?

thanks

Update

self.itemFrame = tk.Frame(parent)
self.itemFrame.pack(expand=False, side=tk.TOP)

removeB = tk.Button(self.itemFrame, text="Remove", width=10, command=self.removeIsosurface)

def removeIsosurface(self):
    self.itemFrame.Destroy()

Error message:

AttributeError: Frame instance has no attribute 'Destroy'
like image 640
aneuryzm Avatar asked Oct 18 '10 18:10

aneuryzm


1 Answers

To remove, call either frm.pack_forget() or frm.grid_forget() depending on whether the frame was packed or grided.

Then call frm.destroy() if you aren't going to use it again, or hold onto the reference and repack or regrid when you want to show it again.

like image 190
Steven Rumbalski Avatar answered Oct 21 '22 08:10

Steven Rumbalski