Python Forum

Full Version: how to make label or button not visible with the place method?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
how can I make this label visible or not visible using the place method?
I will have to make it visible later in he program but hidden at the start.

window=tk.Tk()

labe2 = tk.Label(window, text="hello",font=('ariel',16),bg=('green'),fg=('white')).place(x=50,y=400)
I tried the three methods I found online. Could not get them to work with the place method either.

Thanks

update
by using the place method I had to use the "place_forget" line to make the label or button invisible.
Please show what you have tried. The code in your post makes no attempt at hiding a label.

Normally you would use pack/pack_forget to have a widget appear/disappear. If you need to place() the widget (which I think is a terrible idea), pack the widget in a frame, and place the frame.

A few comments about your example:

Why do you do this bg=('green') instead of this bg('green'? The parenthesis are not needed.

.place(x=50,y=400) returns None, which means labe2 is None.
When you have a reference correctly to the label correctly by calling the place method separately as noted by deanhystad.
You can then use the place_forget method.