December 2015
Beginner to intermediate
350 pages
6h 49m
English
In this recipe, we will create three tkinter Radiobutton widgets. We will also add some code that changes the color of the main form depending upon which Radiobutton is selected.
This recipe extends the previous recipes.
We are adding the following code to the previous recipe:
# Radiobutton Globals # 1 COLOR1 = "Blue" # 2 COLOR2 = "Gold" # 3 COLOR3 = "Red" # 4 # Radiobutton Callback # 5 def radCall(): # 6 radSel=radVar.get() if radSel == 1: win.configure(background=COLOR1) elif radSel == 2: win.configure(background=COLOR2) elif radSel == 3: win.configure(background=COLOR3) # create three Radiobuttons # 7 radVar = tk.IntVar() # 8 rad1 = tk.Radiobutton(win, text=COLOR1, variable=radVar, value=1, ...
Read now
Unlock full access