473,396 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

multiple check boxes


hi,
i am trying to use multiple checkboxes.
what is happening is once select check box its
variable is not getting set. below is the code. what
could be the problem? i am using python 2.0
thanks in advance
=============
from Tkinter import *

def TestCases():

print 'hi'
if(name3.var.get() == 1):
print 'TEST CASE A'
def hostTC():
if(name1.var.get() == 1):
print 'TESTSCENARIO A'
top = Tk()
y1 = IntVar()
name3 = Checkbutton(top, text = "TEST CASE A",
variable = y1, onvalue=1, offvalue=0)
name3.grid()
y2 = IntVar()
name4 = Checkbutton(top, text="TEST CASE B",
variable = y2, onvalue=1, offvalue=0)
name4.grid()
name3.var = y1
name4.var = y2
b1 = Button(top,
text='OK!',command=TestCases())
name3.pack()
name4.pack()
b1.pack()
Tkinter.mainloop()

def main():
global root,name1,name2,name3
root = Tk()
x1 = IntVar()
name1 = Checkbutton(root, text = "Pizza", variable
= x1, onvalue=1, offvalue=0)
name1.grid()
x2 = IntVar()
name2 = Checkbutton(root, text="Salad", variable =
x2, onvalue=1, offvalue=0)
name2.grid()
name1.var = x1
name2.var = x2
b = Button(root, text='OK!',command=hostTC())
name1.pack()
name2.pack()
b.pack()
Tkinter.mainloop()
if __name__ == '__main__':

main()

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

Jul 18 '05 #1
1 4182
Harish Vaidya wrote:

hi,
i am trying to use multiple checkboxes.
what is happening is once select check box its
variable is not getting set. below is the code. what
could be the problem? i am using python 2.0
thanks in advance
I do not fully understand what you're are trying to achieve with your code,
but this observation might help you anyway:

[...] b1 = Button(top,
text='OK!',command=TestCases()) [...] b = Button(root, text='OK!',command=hostTC())

[...]

In both cases you do the eqivalent of

b = Button(..., command=None)

as both TestCases() and hostTC() do not explicitly return a value.
You probably want the buttons to invoke TestCases() or hostTC(), and you
therefore must omit the trailing (), e. g.:

b = Button(root, text='OK!',command=hostTC)

Peter
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pax S | last post by:
I need a button that will check (make true) two check boxes (fields) For the record that has the focus (the record on the form that I am presently looking at). The two check boxes would be like a...
1
by: Jim in Arizona | last post by:
I'm having dificulty figuring out how to process multiple check boxes on a web form. Let's say I have three check boxes: cbox1 cbox2 cbox3 The only way I can think of to code the...
7
by: Siv | last post by:
Hi, I have an MDI application that uses a generic "ShowPage" routine in a module that is called when I want to display a child form. The basic idea is that in the module I have declared each form...
10
by: Jim in Arizona | last post by:
I'm having dificulty figuring out how to process multiple check boxes on a web form. Let's say I have three check boxes: cbox1 cbox2 cbox3 The only way I can think of to code the...
6
by: Harshpandya | last post by:
Hi all, I am working on the form in which you fill out the whole PHP form and e mail that details to someone. It is working fine. But now i want to send the same form to be sent to different...
3
by: Search & You Will Find | last post by:
I have a database in Access 2000 that I need some help on. I have three tables: PROJECTS, SYSTEMS, & SYSTEMSREF. They possess the following fields: -----------------------------------...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
6
by: woodey2002 | last post by:
Hi Everyone. Thanks for your time. I am trying to create a search form that will allow users to select criteria from multiple multi select boxes. So far i have managed to achieve a search option...
1
by: woodey2002 | last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on. My databse mostly includes...
7
by: Humakt | last post by:
This is 2D game where there are breakable boxes in the middle two bats on both sides and one or more balls breaking the boxes. Kind of like a mixup of pong and breakout. Collision detection...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.