I was wondering if there is a smart way of enabling the mouse wheel in the Tk widget 'Spinbox' in Python.
The only sensible solution I found so far was to derive a new spinbox class with the wanted functionality:
class Spinbox(tk.Spinbox):
def __init__(self, *args, **kwargs):
tk.Spinbox.__init__(self, *args, **kwargs)
self.bind('<MouseWheel>', self.mouseWheel)
self.bind('<Button-4>', self.mouseWheel)
self.bind('<Button-5>', self.mouseWheel)
def mouseWheel(self, event):
if event.num == 5 or event.delta == -120:
self.invoke('buttondown')
elif event.num == 4 or event.delta == 120:
self.invoke('buttonup')
But given that this would probably be the expected behavior, I am suspecting there is a better solution.