From 23c89bd091cf865b1dcff7339f6998a4bbbb3b24 Mon Sep 17 00:00:00 2001 From: Urban Wallasch Date: Tue, 4 May 2021 19:33:07 +0200 Subject: [PATCH] * Consolidated all scroll event handling into one funtion. --- ffpreview.py | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/ffpreview.py b/ffpreview.py index ed217c9..6d14a78 100755 --- a/ffpreview.py +++ b/ffpreview.py @@ -338,28 +338,24 @@ scrollframe.bind( canvas.create_window((0, 0), window=scrollframe, anchor='nw') canvas.configure(yscrollcommand=scrollbar.set) -def page_scroll(event): +def on_scroll(event): if event.keysym == 'Next': canvas.yview_scroll(1, 'pages') - if event.keysym == 'Prior': + elif event.keysym == 'Prior': canvas.yview_scroll(-1, 'pages') - -def home_end_scroll(event): - if event.keysym == 'Home': + elif event.keysym == 'Home': canvas.yview_moveto(0) - if event.keysym == 'End': + elif event.keysym == 'End': canvas.yview_moveto(1) - -def mouse_wheel(event): - if event.num == 5 or event.delta == -120 or event.keysym == 'Down': + elif event.num == 5 or event.delta == -120 or event.keysym == 'Down': canvas.yview_scroll(1, 'units') - if event.num == 4 or event.delta == 120 or event.keysym == 'Up': + elif event.num == 4 or event.delta == 120 or event.keysym == 'Up': canvas.yview_scroll(-1, 'units') def bind_mousewheel(event): - canvas.bind_all('', mouse_wheel) # Windows mouse wheel event - canvas.bind_all('', mouse_wheel) # Linux mouse wheel event (Up) - canvas.bind_all('', mouse_wheel) # Linux mouse wheel event (Down) + canvas.bind_all('', on_scroll) # Windows mouse wheel event + canvas.bind_all('', on_scroll) # Linux mouse wheel event (Up) + canvas.bind_all('', on_scroll) # Linux mouse wheel event (Down) def unbind_mousewheel(event): canvas.unbind_all('') @@ -368,12 +364,12 @@ def unbind_mousewheel(event): container.bind_all('', bind_mousewheel) container.bind_all('', unbind_mousewheel) -container.bind_all('', mouse_wheel) # CursorUp key -container.bind_all('', mouse_wheel) # CursorDown key -container.bind_all('', home_end_scroll) # Home key -container.bind_all('', home_end_scroll) # End key -container.bind_all('', page_scroll) # PageUp key -container.bind_all('', page_scroll) # PageDn key +container.bind_all('', on_scroll) # CursorUp key +container.bind_all('', on_scroll) # CursorDown key +container.bind_all('', on_scroll) # Home key +container.bind_all('', on_scroll) # End key +container.bind_all('', on_scroll) # PageUp key +container.bind_all('', on_scroll) # PageDn key ilabel = [ Label(scrollframe, text='Generating view ...', width=15, height=2, anchor='w'), -- 2.30.2