Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def radcall():
- radSel = radVar.get()
- if radSel ==1:
- win.configure(background=COLOR1)
- elif radSel == 2:
- win.configure(background=COLOR2)
- elif radSel == 3:
- win.configure(background=COLOR3)
- #creating 3 radiobuttons
- radVar=tk.IntVar()
- rad1 = tk.Radiobutton(win, text =COLOR1, variable=radVar, value=1,
- command=radcall)
- rad1.grid(column=0,row=4)
- rad2 = tk.Radiobutton(win, text = COLOR2, variable=radVar, value=2,
- command=radcall)
- rad2.grid(column=1,row=4)
- rad3 = tk.Radiobutton(win, text = COLOR3, variable=radVar, value=3,
- command=radcall)
- rad3.grid(column=2,row=4)
- class radbut():
- def __init__(self,win,text,variable,value,col,ro):
- self.win=win
- self.text=text
- self.variable=variable
- self.value=value
- self.col=col
- self.ro=ro
- def configure(self):
- if self.variable==1:
- print("in if statement")
- self.win.configure(background=COLOR1)
- return tk.Radiobutton(self.win,self.text,self.variable,self.value).grid(column = self.col,row = self.ro)
- elif self.variable == 2:
- self.win.configure(background=COLOR2)
- return tk.Radiobutton(self.win,self.text,self.variable,self.value).grid(column = self.col,row = self.ro)
- elif self.variable == 3:
- self.win.configure(background=COLOR3)
- return tk.Radiobutton(self.win,self.text,self.variable,self.value).grid(column = self.col,row = self.ro)
- cast = radbut(win,COLOR1,'BLUE',1,0,4)
- cast.configure()
Add Comment
Please, Sign In to add comment