'TKInter Option list to run a command to move to next level
I have attempted to create a function that will look at the current value in the OptionList and run the assigned code depending on its value.
Here I have set-up the values.
OptionList1 = [
"Choose your spell!", "Avada Kedavra", "Sectumsempra", "Expelliarmus",
"Riddikulus"
]
clicked = tkinter.StringVar()
clicked.set(OptionList1[0])
drop = tkinter.OptionMenu(window, clicked, *OptionList1)
drop.config(width=50, font=('Times', 12))
drop.pack()
button = tkinter.Button(window, text="OK", command=print_answers)
button.pack()
Here I have the function that runs depending on the value of the OptionList
def print_answers():
if OptionList1 == OptionList1[3]:
Survived()
else:
TheEnd()
I don't know what I am missing to make the code run properly. Below is a link to the whole project code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
