Reputation: 9521
I have a tkinter spinbox widget.
val = IntVar()
Spinbox(from_=1, to=10, textvariable=val, command=lambda:self.Fn(val.get()))
def Fn(self, v):
print v
When the spinbox is clicked, it prints value of new spin box value.
Instead I want the previous spinbox value - which could be one above or one below the current value.
Is there a way i can get the previous value ?
Upvotes: 3
Views: 2880
Reputation: 20679
You just need to store the value, and print it the next time the function is called:
def Fn(self, v):
result = self._oldvalue
self._oldvalue = v
print(result)
Don't forget to initialize self._oldvalue
with some default value.
Upvotes: 5