Tkinter toggle a Label Widget based on checkbutton value

O.R.Senthil Kumaran orsenthil at users.sourceforge.net
Wed Jul 4 23:02:56 EDT 2007


* Wojciech Mu?a <wojciech_mula at poczta.null.onet.pl.invalid> [2007-07-04 20:13:06]:

> O.R.Senthil Kumaran wrote:
> > 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.
> >
> > #!/usr/bin/python
> > from Tkinter import *
> > root = Tk()
> > root.title('something')
> > x = StringVar()
> 
> ip = Label(root,text="IP:")
> > def display():
>       global ip
> >     if x.get():
> >         #ip = Label(root,text="IP:")
> >         ip.grid(row=3,column=0)
>        else:
>           ip.grid_forget()


Thanks a lot, that perfectly does the trick. :-) Did not know about
grid_forget() earlier.


-- 
O.R.Senthil Kumaran
http://uthcode.sarovar.org



More information about the Python-list mailing list