hiding a frame in tkinter

F

faramarz yari

hello everybody
suppose we have a tk frame in witch there are lots of frame,
and we want to hide one of them(frames)
what should we do , and what will be the result in pack or grid goemetry?
thank you in advanced
 
H

Harlin Seritt

faramarz,

Most likely, you'll need to replace the 'forgotten' frame with another
one or other widget. You can immediately do *.pack() and it will
replace the frame (assumming you haven't already packed something else
there).

Harlin Seritt
 
F

faramarz yari

lots of thanks to the nice guys of python community,

i do it ,and it works just as i want,
but unfourtunatly a new problem arise.
the problem is :
when i use pack_forget , i just work,
but suppose we want to call it in func or method,
i choose to test it in a func:

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.
so how can i send a pointer (refrence) of an object to a func or method.
should i use any prop. of frame instance(ex:f3)?
in other words i want to know how can i send
arg as refrence in python.(ex: object of general MyClass)?
thank you again





i am a real newbie in python & tkinter,
 
F

Fredrik Lundh

faramarz yari said:
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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,253
Latest member
BlytheFant

Latest Threads

Top