Connecting Tech Pros Worldwide Help | Site Map

Re: Tkinter/WindowsXP - how to use checkbutton to toggle a label inGUI?

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 21st, 2008, 02:45 PM
Gabriel Genellina
Guest
 
Posts: n/a
Default Re: Tkinter/WindowsXP - how to use checkbutton to toggle a label inGUI?

En Thu, 21 Aug 2008 05:07:45 -0300, <dudeja.rajat@gmail.comescribi�:
Quote:
I've a checkbutton in my GUI application which I want to work as:
>
1. it should be un-ticked by default,
2. should display a label in Gui, by default,
3. when user ticks the check button this should the above label goes
off the screen and not longer is
displayed.
>
Please suggest how could I do this:
Use the grid_forget method to hide the label. Based on your posted example:

from Tkinter import *

def onclick():
if varTestAll.get(): lblVersionUnderTest.grid_forget()
else: lblVersionUnderTest.grid(row=2, column=1)

master = Tk()
varTestAll = IntVar()
cbTestAll = Checkbutton(master, text="Test All", variable=varTestAll,
command=onclick)
cbTestAll.grid(row=1, column=1)
lblVersionUnderTest = Label(master, text = "v2.1.5.0")
lblVersionUnderTest.grid(row=2, column=1)
mainloop()

But completely removing the label from the window looks strange. I'd
disable it; just replace the onclick function with this other one:

def onclick():
if varTestAll.get(): lblVersionUnderTest.config(state=DISABLED)
else: lblVersionUnderTest.config(state=NORMAL)

--
Gabriel Genellina


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.