I am trying to assign a value to a variable using a radio button in python with the following code:
def print_me():
global payment
global membership
if studentMemString == "PY_VAR0":
membership = "STUDENT"
payment = studentMem
elif adultMemString == "PY_VAR10":
membership = "ADULT"
payment = adultMem
elif childMemString == "PY_VAR0":
membership = "CHILD"
payment = childMem
else:
pass
print(membership)
print(payment)
root = tk.Tk()
studentMem = tk.StringVar()
studentMemString = str(studentMem)
adultMem = tk.StringVar()
adultMemString = str(adultMem)
childMem = tk.StringVar()
childMemString = str(childMem)
studentRadBtn = tk.Radiobutton(root, text="Student - £19.99",
variable=studentMem, value= 19.99)
studentRadBtn.pack()
adultRadBtn = tk.Radiobutton(root, text="Adult - £34.99", variable=adultMem,
value= 34.99)
adultRadBtn.pack()
childRadBtn = tk.Radiobutton(root, text="Child - £5.99", variable=childMem,
value=5.99)
childRadBtn.pack()
button = tk.Button(root, text="click", command=print_me)
button.pack()
root.mainloop()
(update) Okay So now the issue is that when i start the program all the radio buttons are active and regardless of which one I try to click on the only one that is called is the first one. Why are they all selected?