Hi,

Thus spoketh <p...@vtr.net> 
unto us on Fri, 07 Jan 2011 13:44:14 -0300:

> Hi.
> 
> I'm testing the ability to pack and unpack a Frame control.
> 
> The code I use is:
> -----------------------------------------------------------
> 
> import Tkinter
> import ttk
> 
> class App:
>       def __init__(self, master):
>               self.root = master
>               self.frame = ttk.Frame(self.root, style='TFrame')
>               self.frame.pack(fill='both', expand='yes')
>               
>               self.b1 =  ttk.Button(self.root, text='unpack')
>               self.b1.pack()
>               
>               self.b2 = ttk.Button(self.root, text='pack')
>               self.b2.pack()
>               
>               
>               self.b1.bind('<Button-1>', lambda e, widget=self:unpack
> (widget)) self.b2.bind('<Button-1>', lambda e, widget=self:pack(widget))
>               
> def pack(widget):
>       widget.frame.pack()
>       print (widget.frame.pack_info())
>       
> def unpack(widget):
>       widget.frame.pack_forget()
>       
>       
> 
> master = Tkinter.Tk()
> master.geometry('640x480')
> s = ttk.Style()
> s.configure('TFrame', background='blue')
> app = App(master)
> master.mainloop()
> -----------------------------------------------------------
> 
> Unpacking the Frame work, but in trying to repackage it does not work.

Actually it does work, however you do not see the frame, because there
aren't any widgets inside it and you did not use the fill='both',
expand='yes' flags when you re-packed it, so it will end up with 1x1
pixels size. Here I can still see the blue pixel if I look closely right
under the "pack" button :)

Regards

Michael


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

Knowledge, sir, should be free to all!
                -- Harry Mudd, "I, Mudd", stardate 4513.3
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to