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

Michael Lange klappnase at web.de
Thu Dec 9 15:51:23 CET 2010


Thus spoketh python at bdurham.com 
unto us on Thu, 09 Dec 2010 09:25:33 -0500:

> Is there a pack equivalent of the grid_remove() method where a
> widget's original pack() settings are restored on a re-pack()?
> Use case: When I show a packed widget that has been hidden via
> pack_forget(), I would like to have the widget re-packed with its
> original pack settings when I issue the widget.pack() show
> request.

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

from Tkinter import *
root = Tk()

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):

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


I hope this helps


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

We're all sorry for the other guy when he loses his job to a machine.
But when it comes to your job -- that's different.  And it always will
be different.
		-- McCoy, "The Ultimate Computer", stardate 4729.4

More information about the Tkinter-discuss mailing list