Guest User

Untitled

a guest
Oct 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. def radcall():
  2. radSel = radVar.get()
  3. if radSel ==1:
  4. win.configure(background=COLOR1)
  5. elif radSel == 2:
  6. win.configure(background=COLOR2)
  7. elif radSel == 3:
  8. win.configure(background=COLOR3)
  9.  
  10. #creating 3 radiobuttons
  11. radVar=tk.IntVar()
  12. rad1 = tk.Radiobutton(win, text =COLOR1, variable=radVar, value=1,
  13. command=radcall)
  14. rad1.grid(column=0,row=4)
  15. rad2 = tk.Radiobutton(win, text = COLOR2, variable=radVar, value=2,
  16. command=radcall)
  17. rad2.grid(column=1,row=4)
  18. rad3 = tk.Radiobutton(win, text = COLOR3, variable=radVar, value=3,
  19. command=radcall)
  20. rad3.grid(column=2,row=4)
  21.  
  22. class radbut():
  23.  
  24. def __init__(self,win,text,variable,value,col,ro):
  25. self.win=win
  26. self.text=text
  27. self.variable=variable
  28. self.value=value
  29. self.col=col
  30. self.ro=ro
  31.  
  32. def configure(self):
  33. if self.variable==1:
  34. print("in if statement")
  35. self.win.configure(background=COLOR1)
  36. return tk.Radiobutton(self.win,self.text,self.variable,self.value).grid(column = self.col,row = self.ro)
  37. elif self.variable == 2:
  38. self.win.configure(background=COLOR2)
  39. return tk.Radiobutton(self.win,self.text,self.variable,self.value).grid(column = self.col,row = self.ro)
  40. elif self.variable == 3:
  41. self.win.configure(background=COLOR3)
  42. return tk.Radiobutton(self.win,self.text,self.variable,self.value).grid(column = self.col,row = self.ro)
  43. cast = radbut(win,COLOR1,'BLUE',1,0,4)
  44. cast.configure()
Add Comment
Please, Sign In to add comment