lundi 6 juillet 2015

dynamically creating checkboxes from a list of checkboxes in tkinter python 2.7

I am trying to create new checkboxes from a list of checkboxes but in a new frame. The newly created checkboxes however act like radiobuttons when created at the same time. Here is the code (only for the function creating the boxes)

def printcheckbuttons():
    val=StringVar()#checkboxlist is a list of checkbox widgets
    for x in range (len(checkboxlist)):
        for ki in checkboxlist:
            if ki.var.get() != 'null':
                sale=Checkbutton(frameright,text=ki.var.get()[0:],variable=val,onvalue=ki.var.get(),offvalue='null')
                sale.val=val
                saletracker.append(sale)#saletracker is a list to track selected checkboxes in checkboxlist ant post them to a second frame
                sale.pack(anchor=NW)           
                checkboxlist.remove(ki)
                ki.destroy()
                print 'checkboxlist 1',checkboxlist
   destroyboxes(checkboxlist)#destroys and removes all checkboxes in checkbuttonlist
   print 'checkboxlist',checkboxlist
   print "saletracker ", saletracker




Aucun commentaire:

Enregistrer un commentaire