[Tkinter-discuss] pack equivalent of grid_remove(), eg. pack_remove() ?
Michael Lange
klappnase at web.de
Thu Dec 9 15:51:23 CET 2010
Hi,
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()
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()
I hope this helps
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
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