Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> root = Tkinter.Tk()
- >>> var = Tkinter.IntVar()
- >>> chk = Tkinter.Checkbutton(root, text='foo', variable=var)
- >>> chk.pack(side=Tkinter.LEFT)
- >>> var.get() #unchecked
- 0
- >>> var.get() #checked
- 1
- >>> import tkinter
- >>> from tkinter import ttk
- >>> tkwindow = tkinter.Tk()
- >>> chk = ttk.Checkbutton(tkwindow, text="foo")
- >>> chk.grid(column=0, row=0)
- >>> print(chk.state()) # half-checked
- ('alternate',)
- >>> print(chk.state()) # checked
- ('selected',)
- >>> print(chk.state()) # not checked
- ()
- >>> chk.state(['selected']) # check the checkbox
- >>> chk.state(['!selected']) # clear the checkbox
- >>> chk.state(['disabled']) # disable the checkbox
- >>> chk.state(['!disabled','selected']) # enable the checkbox and put a check in it!
- >>> chk.state(['!alternate'])
- >>> chk.instate(['selected']) #returns True or False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement