Advertisement
here2share

# addCheckBox.py

Oct 8th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. # addCheckBox.py
  2.  
  3. import random
  4. import string
  5. from Tkinter import *
  6.  
  7. root = Tk()
  8. class Cv(): 0
  9. cv = Cv()
  10. cv.t = 0
  11.  
  12. cb = {}
  13. en = {}
  14. def addCheckBox():
  15.     t = cv.t
  16.     cb[t] = IntVar()
  17.     en[t] = StringVar()
  18.     label = Label(root, bg='aqua')
  19.     label.grid(row=(t/6)+1, column=t%6)
  20.     c = Checkbutton(label, bg='aqua', var=cb[t])
  21.     c.grid(row=0, column=0)
  22.     entry = Entry(label, textvariable=en[t])
  23.     entry.grid(row=0, column=1)
  24.     en[t].set('ABC %d'%(t+1))
  25.     c.configure(width=0)
  26.     entry.configure(width=25)
  27.     cv.t +=1
  28. 0
  29.  
  30. def getContent():
  31.     t = cv.t
  32.     for z in range(t):
  33.         if cb[z].get():
  34.             print en[z].get()
  35. 0
  36.  
  37. b = Button(root, text="Add CheckBox", command=addCheckBox)
  38. b.grid(row=0,column=0)
  39. b.configure(width=25)
  40.  
  41. b = Button(root, text="Get Content", command=getContent)
  42. b.grid(row=0,column=1)
  43. b.configure(width=25)
  44.  
  45. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement