Python Forum
[Tkinter] how to make label or button not visible with the place method?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] how to make label or button not visible with the place method?
#1
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.
Yoriz write Jan-03-2023, 06:15 AM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
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.
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] cutomtkinter matplotlib no x,y - xaxis and x,y - labels-> only graph and grid visible dduric 0 233 Feb-20-2024, 07:09 PM
Last Post: dduric
  Place QT Window in the middle AlphaInc 10 2,041 Aug-03-2023, 05:40 PM
Last Post: Axel_Erfurt
Question [Tkinter] How to make split button? teknixstuff 2 1,019 Jan-03-2023, 06:21 PM
Last Post: Yoriz
  [PyQt] Determine whether text in QTableView cell is fully visible or not random_nick 0 957 Oct-27-2022, 09:29 PM
Last Post: random_nick
  [WxPython] [SOLVED] How to change button label? Winfried 3 2,020 May-31-2022, 06:37 PM
Last Post: Winfried
  [Tkinter] Make my button text update? Skata100 1 2,012 Aug-07-2021, 05:37 AM
Last Post: deanhystad
  Label.Place did not work? ATARI_LIVE 15 5,056 Sep-18-2020, 04:22 PM
Last Post: ATARI_LIVE
  [Tkinter] How to place scroll bar correctly scratchmyhead 1 3,896 May-18-2020, 04:17 PM
Last Post: scratchmyhead
  How to make button text bold in Tkinter? scratchmyhead 2 11,906 May-16-2020, 02:53 AM
Last Post: scratchmyhead
  How to use place holders in tkinter sqlite scratchmyhead 1 1,782 May-12-2020, 06:13 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020