[Tkinter-discuss] pack equivalent of grid_remove(), eg. pack_remove() ?

python at bdurham.com python at bdurham.com
Fri Dec 10 15:23:35 CET 2010


Michael,

Your pack_forget() code works like a charm!

Thank you,
Malcolm


<snipped>

From: "Michael Lange" <klappnase at web.de>
To: tkinter-discuss at python.org
Date: Thu, 9 Dec 2010 15:51:23 +0100

There's nothing like that built in, but it is quite easy to set it up:

from Tkinter import *
root = Tk()
root.geometry('200x200')

class pFrame(Frame):
    def __init(self, *args, **kw):
        Frame.__init__(self, *args, **kw)
        self._packinfo = {}

    def pack(self, *args, **kw):
        Frame.pack(self, *args, **kw)
        self._packinfo = self.pack_info()
    pack_configure = pack

    def pack_recall(self):
        self.pack(**self._packinfo)


f = pFrame(root, bg='yellow')
f.pack(fill='both', expand=1)
f.pack_forget()
f.pack_recall()

root.mainloop()

</snipped>


More information about the Tkinter-discuss mailing list