Python Forum
[Tkinter] TkInter toggle Label on/off
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] TkInter toggle Label on/off
#1
How can i get a TkInter Label to toggle on off? the toggle on works the label isnt visable upon start and then appears when the checkbutton is pressed (=1), however when the button is pressed again (=0)the label remains.

def STIC_Sel():
    STIC_Sel_State = var1.get()
    if (STIC_Sel_State == 1):
            print("Test STIC Selected")
            IPT_Display_STIC = Label(IPT, text=Output_IP_Address_STIC, anchor=W)
            IPT_Display_STIC_Window = canvas_IPT.create_window(150, 160, anchor = 'sw', window = IPT_Display_STIC)
    else:
            print("STIC Not Selected")
var1 = IntVar()
IPT_Test_STIC = Checkbutton(IPT, text = "STIC", justify=LEFT,width=15, indicatoron=0,
                                variable = var1, command=STIC_Sel)
IPT_Test_STIC_Window = canvas_IPT.create_window(20, 165, anchor = 'sw', window = IPT_Test_STIC)

I have tried

def STIC_Sel():
    STIC_Sel_State = var1.get()
    if (STIC_Sel_State == 1):
            print("Test STIC Selected")
            IPT_Display_STIC = Label(IPT, text=Output_IP_Address_STIC, anchor=W)
            IPT_Display_STIC_Window = canvas_IPT.create_window(150, 160, anchor = 'sw', window = IPT_Display_STIC)
    else:
            print("STIC Not Selected")
            IPT_Display_STIC = Label(IPT, text="Not Selected For Test", anchor=W)
            IPT_Display_STIC_Window = canvas_IPT.create_window(150, 160, anchor = 'sw', window = IPT_Display_STIC)
But this just generates a label on top of the previous one
Reply


Messages In This Thread
TkInter toggle Label on/off - by MTom5 - Aug-14-2018, 07:27 PM
RE: TkInter toggle Label on/off - by Larz60+ - Aug-14-2018, 10:00 PM
RE: TkInter toggle Label on/off - by metulburr - Aug-15-2018, 12:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter: An image and label are not appearing. emont 7 678 Mar-21-2024, 03:00 PM
Last Post: deanhystad
  tkinter destroy label inside labelFrame Nick_tkinter 3 4,578 Sep-17-2023, 03:38 PM
Last Post: munirashraf9821
  [Tkinter] Updating Tkinter label using multiprocessing Agusms 6 3,184 Aug-15-2022, 07:10 PM
Last Post: menator01
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 4,954 Jun-26-2022, 06:26 PM
Last Post: menator01
  tkinter toggle buttons not working Nu2Python 26 7,051 Jan-23-2022, 06:49 PM
Last Post: Nu2Python
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 5,054 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  tkinter: Image to Label Maryan 10 5,334 Oct-29-2020, 01:48 PM
Last Post: joe_momma
  Tkinter - How can I extend a label widget? TurboC 2 2,813 Oct-13-2020, 12:15 PM
Last Post: zazas321
  Tkinter: How to assign calculated value to a Label LoneStar 7 3,900 Sep-03-2020, 08:19 PM
Last Post: LoneStar
  changing tkinter label from thread nanok66 3 7,398 Jun-07-2020, 01:37 AM
Last Post: nanok66

Forum Jump:

User Panel Messages

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