Checkbox button bar : Checkbutton : Tkinker PYTHON TUTORIALS


PYTHON TUTORIALS » Tkinker » Checkbutton »

 

Checkbox button bar


Checkbox button bar
from Tkinter import *
     
class Checkbar(Frame):
    def __init__(self, parent=None, picks=[], side=LEFT, anchor=W):
        Frame.__init__(self, parent)
        self.vars = []
        for pick in picks:
            var = IntVar()
            chk = Checkbutton(self, text=pick, variable=var)
            chk.pack(side=side, anchor=anchor, expand=YES)
            self.vars.append(var)
    def state(self):
        return [var.get() for var in self.vars]  

root = Tk()
checkBoxBar = Checkbar(root, ['A''B''C''D'])

checkBoxBar.pack(side=TOP,  fill=X)

checkBoxBar.config(relief=GROOVE, bd=2)

def allstates()
   print checkBoxBar.state()

Button(root, text='Peek', command=allstates).pack(side=RIGHT)
root.mainloop()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Tkinker
» Checkbutton