471,595 Members | 1,106 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

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

En Thu, 21 Aug 2008 05:07:45 -0300, <du**********@gmail.comescribi�:
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

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,
cbTestAll.grid(row=1, column=1)
lblVersionUnderTest = Label(master, text = "v2.1.5.0")
lblVersionUnderTest.grid(row=2, column=1)

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

Aug 21 '08 #1
0 842

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Rick Olson | last post: by
5 posts views Thread by max(01)* | last post: by
1 post views Thread by Michael Yanowitz | last post: by
1 post views Thread by Kevin Walzer | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.