petri_dish
changeset 18:9fa0119fa63c
Added reasonable binding for mousewheel to Scroll widget
author | Daniil Alexeyevsky <me.dendik@gmail.com> |
---|---|
date | Wed, 15 Dec 2010 16:21:26 +0300 |
parents | 15d7afe555a4 |
children | b78c555543a8 |
files | scale.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- a/scale.py Wed Dec 15 15:49:24 2010 +0300 1.2 +++ b/scale.py Wed Dec 15 16:21:26 2010 +0300 1.3 @@ -60,11 +60,20 @@ 1.4 def depict(self): 1.5 pass 1.6 1.7 +def update_scale(widget, times): 1.8 + value = widget.get() 1.9 + length = widget['to'] - widget['from'] 1.10 + value += length * times / 10 1.11 + widget.set(value) 1.12 + 1.13 root = Tk() 1.14 root.title("Interface") 1.15 intf=IF() 1.16 c=Canvas() 1.17 1.18 +root.bind_class("Scale", "<4>", lambda ev: update_scale(ev.widget, +1)) 1.19 +root.bind_class("Scale", "<5>", lambda ev: update_scale(ev.widget, -1)) 1.20 + 1.21 menubar = Menu(root) 1.22 1.23 # create a pulldown menu, and add it to the menu bar