user interface - Enable mouse wheel in Spinbox Tk Python -


i wondering if there smart way of enabling mouse wheel in tk widget 'spinbox' in python.

the sensible solution found far derive new spinbox class 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 expected behavior, suspecting there better solution.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -