[Tkinter] how to make label or button not visible with the place method? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Tkinter] how to make label or button not visible with the place method? (/thread-39106.html) |
how to make label or button not visible with the place method? - nowayj63 - Jan-03-2023 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. RE: how to make label or button not visible with the place method? - deanhystad - Jan-03-2023 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.
RE: how to make label or button not visible with the place method? - Yoriz - Jan-03-2023 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.
|