multiple checkboxes highlighted when one clicked = not good

MooMaster ntv1534 at gmail.com
Wed Jul 6 01:11:45 CEST 2005


I've been reading Deitel's Introducing Python, and Fredrik Lundh's
Introduction to Tkinter, trying to familiarize myself with Python and
GUI design in Tk, and I've run into a puzzling problem. I'm trying to
draw a column of 10 checkboxes, each with a separate variables and
commands. The easy way to do this is to hardcode it, but I was trying
to do something a little more elegant:

 self.InUse =[BooleanVar(), BooleanVar(), BooleanVar(), BooleanVar(),
BooleanVar(), BooleanVar(), BooleanVar()]

        for i in range(1,11):
            for t in range(7):
                if(t==0):
                    Checkbutton(self.frame2, variable =
self.InUse[t]).grid(row= i, column = t)


I figure since I create a separate variable for each checkbutton, the
should be independent of one another. Unfortunately, they are not, and
when I click on one, all become selected/deselected. What am I missing?

Thanks!




More information about the Python-list mailing list