The user should pick a matter from the list in the dropdown menu. Then it would give back a schematic drawing of that matter with the Turtle mudole, i do not include that here. I would want it to wait computing
m = n - 1
after the user's input is registered.
from tkinter import *
OPTIONS = ['methaan','ethaan','propaan','butaan']
master = Tk()
variable = StringVar(master)
variable.set(OPTIONS[0]) # default value
w = OptionMenu(master, variable, *OPTIONS)
w.pack()
def ok():
variable.get()
if variable == 'methaan':
n = 1
elif variable == 'ethaan':
n = 2
elif variable == 'propaan':
n = 3
elif variable == 'butaan':
n = 4
button = Button(master, text="OK", command=ok)
button.pack()
m = n - 1
print(m)
mainloop()
It gives back that n is not defined.
Desired outcome
# 0 to 3 depending on what matter you choose.
Thank you in advance.