Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. >>> root = Tkinter.Tk()
  2. >>> var = Tkinter.IntVar()
  3. >>> chk = Tkinter.Checkbutton(root, text='foo', variable=var)
  4. >>> chk.pack(side=Tkinter.LEFT)
  5. >>> var.get() #unchecked
  6. 0
  7. >>> var.get() #checked
  8. 1
  9.  
  10. >>> import tkinter
  11. >>> from tkinter import ttk
  12. >>> tkwindow = tkinter.Tk()
  13. >>> chk = ttk.Checkbutton(tkwindow, text="foo")
  14. >>> chk.grid(column=0, row=0)
  15.  
  16. >>> print(chk.state()) # half-checked
  17. ('alternate',)
  18. >>> print(chk.state()) # checked
  19. ('selected',)
  20. >>> print(chk.state()) # not checked
  21. ()
  22.  
  23. >>> chk.state(['selected']) # check the checkbox
  24. >>> chk.state(['!selected']) # clear the checkbox
  25. >>> chk.state(['disabled']) # disable the checkbox
  26. >>> chk.state(['!disabled','selected']) # enable the checkbox and put a check in it!
  27.  
  28. >>> chk.state(['!alternate'])
  29.  
  30. >>> chk.instate(['selected']) #returns True or False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement