Tkinter toggle a Label Widget based on checkbutton value

O.R.Senthil Kumaran orsenthil at
Wed Jul 4 21:51:34 CEST 2007

Following is a tk code, which will display a checkbutton, and when checkbox is
enabled, it will show the below present Label.

What I was trying is, when checkbox is enabled the Label should be shown and
when checkbox is disabled, the window should look like before.

But, I am finding that once enabled (shown), its not very-straightforward to
hide it from the window.

Any suggestions on  how can i make this checkbutton effect.
1) Press Enable IP, the Label IP should be shown.
2) Toggle Enable IP (So that its unset). the Label IP should not be shown.

from Tkinter import *
root = Tk()
x = StringVar()
def display():
    if x.get():
        ip = Label(root,text="IP:")

proxy = Checkbutton(root, text="Enable IP:", variable = x,onvalue="proxy",

O.R.Senthil Kumaran

More information about the Python-list mailing list