Python‎ > ‎tkinter‎ > ‎

tkinter.Checkbutton


Definition
The method create the Checkbutton.

Syntax
tkinter.Checkbutton()

Options
Checkbutton(activebackground, activeforeground, anchor, background, bd, bg, bitmap, borderwidth, command, cursor,disabledforeground, fg, font, foreground, height, highlightbackground, highlightcolor, highlightthickness, image, indicatoron, justify, offvalue, onvalue, padx, pady, relief, selectcolor, selectimage, state, takefocus, text, textvariable, underline, variable, width, wraplength)

Examples
The code returns with the Checkbox().
from tkinter import*
master=Tk()

checkbutton1=Checkbutton(master,text="C1")
checkbutton1.pack(side=LEFT)

checkbutton2=Checkbutton(master, text="C2")
checkbutton2.pack(side=RIGHT)

checkbutton3=Checkbutton(master,text="C3")
checkbutton3.pack(side=TOP)

checkbutton4=Checkbutton(master,text="C4")
checkbutton4.pack(side=BOTTOM)

master.mainloop()





The method adjusted text alignment through Checkbutton.grid().
 from tkinter import*
master=Tk()

checkbutton1=Checkbutton(master,text="C1")
checkbutton1.grid(row=1,column=0)

checkbutton2=Checkbutton(master, text="C2")
checkbutton2.grid(row=1,column=2)

checkbutton3=Checkbutton(master,text="C3")
checkbutton3.grid(row=0,column=1)

checkbutton4=Checkbutton(master,text="C4")
checkbutton4.grid(row=2,column=1)

master.mainloop()





The Checkbutton is placed inside the LabelFrame.
 from tkinter import*
master=Tk()

labelframe=LabelFrame(master, text="Your age")
labelframe.pack(side=LEFT)

checkbutton1=Checkbutton(labelframe, text=" 16+")
checkbutton1.pack()

checkbutton2=Checkbutton(labelframe, text=" 30+")
checkbutton2.pack()

checkbutton3=Checkbutton(labelframe, text=" 40+")
checkbutton3.pack()

checkbutton3=Checkbutton(labelframe, text=" 60+")
checkbutton3.pack()

master.mainloop()






tkinter


Comments