Hi all,

I'm trying to learn a bit about how to show/hide objects using the
available layout managers and have no problems using Pack or Grid but
when I try to use Place then I'm missing something

My test code looks like this

from Tkinter import *

def toggle():
    if mylabel.visible:
        mylabel.place_forget()
    else:
        mylabel.place()
    mylabel.visible = not mylabel.visible

root = Tk()

mylabel = Label(text="Example")
mylabel.visible = True
mylabel.place(x=20,y=50)

btnToggle = Button(text="Toggle nr two",command=toggle)
btnToggle.place(x=70,y=150)

root.mainloop()

According to the documentation I've read I should be able to use
'place()' after having used 'place_forget()' to show the label at the
same place.

What happens is on the first click the label disappears, but when I
click again it stays invisible (and yes, the else statement is
executed). If I change the else-statement to
'mylabel.place(x=70,y=150)'

Any idea what I'm missing?

-- 
The Green Tea Leaf   thegreenteal...@gmail.com   thegreentealeaf.blogspot.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to