hiding a frame in tkinter

Fredrik Lundh fredrik at pythonware.com
Tue Mar 29 10:32:35 EST 2005


"faramarz yari" wrote:

> def do_unpack(f):
>    f.pack_forget()
> ...
> b=Button(f3,text="hello",command=do_unpack(f3))
>
> it does not work & the interpreter does not claim any error.

it works perfectly fine, but it doesn't do what you want.

    do_unpack(f3)

is a function call, so you're calling the function *before* you create
the button, and you're then passing the return value (None) to the
button widget.

if you want to use the function as a callback, use a lambda:

    b=Button(..., command=lambda: do_unpack(f3))

or a local function

    def cb():
        do_unpack(f3)
    b=Button(..., command=cb)

</F> 






More information about the Python-list mailing list