How can I do it, that when I push the scale to 3, then push a button and something special happens then? So that I define an action for every variable in the scale. I tried it with if, but it's not working. There is no error. The labels just dont appear. Thanks.
from tkinter import *
mode2f=Tk()
def antmenge(self):
möant["text"]="Mögliche Antworten: " \
+ str(antmengen.get()) + " "
möant=Label(mode2f, text="Mögliche Antworten: 0 Wörter", width=25)
möant.pack()
antmengen=IntVar()
antmengen.set(0)
antm=Scale(mode2f, width=20, length=200, orient="vertical", from_=0, to=1,
resolution=1, tickinterval=10, label="Wörter", command=antmenge,
variable=antmengen)
antm.pack()
def antmengenask():
if antmengen==0:
label=Label(mode2f, text="0")
label.pack()
elif antmengen==1:
label1=Label(mode2f, text="1")
label1.pack()
button=Button(mode2f, text="push", command=antmengenask)
button.pack()
mainloop()
Use antmengen.get()
to get value.
BTW: don't use native chars in variable names (ö
in möant
)