x = IntVar()
x.set(1)
def add():
x.set(x.get()+1)
I am using this piece of code to update the question number on a tkinter quiz I am making.
self.recordNum = Label(self.quizf, text=x)
self.recordNum.pack()
self.Submit = Button(self.quizf, text = 'submit', command=lambda:[self.confirmAnswer(),add()])
I used lambda
so I could have two commands in the same button which I need as self.confirmAnswer
runs the if statement to check the answer and the add
command activates the first piece of code displayed above.
When I run the quiz PY_VAR4
displays instead of a number, thanks for your help! :)