I am trying to create a program that allows user to select from a list of symptoms they have and find the disease.i added a drop-down menu that contains the symptoms in checkboxes
clicked2=StringVar(root)
clicked2.set(symptoms[0])
drop2=OptionsMenu(root,variable=clicked2,value="options :")
drop2.pack()
checked=[] #contain the checked symptoms
def checkedSymptom:
if (var2.get()=1):
checked.append(symptom)
print(symptom)
elif (var2.get()=0):
pass
this is the part I'm having an issue with
for symptom in symptoms:
var2=IntVar()
drop2['menu'].add_checkbutton(label=symptom,onvalue=1,offvalue=0, variable=var2, command=checkedSymptom)
symptoms here is the list of symptoms
but since it loops through the list of symptoms each time it loops the variable that holds the checkbox is overwritten. so at the end only the last item on the list does anything when checked.
-
IntVar.