From d458744d17419b8eee02b5ba3e7934662378c543 Mon Sep 17 00:00:00 2001 From: shreyash <67905454+shreyash@users.noreply.github.com> Date: Mon, 7 Sep 2020 23:47:32 +0530 Subject: [PATCH 1/2] Horizontal scrolling disabled if no overflow When no overflow, scrolling gave division by zero error. This was because the width of scroll bar became 1, and that multiplied by window width became equal to window width. Subtraction of the two gave zero, where Python gave an error. A simple if statement is added so that scrolling is disabled if scroll bar width is 1. --- kivy/uix/scrollview.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kivy/uix/scrollview.py b/kivy/uix/scrollview.py index 3216d81e6..83cf97243 100644 --- a/kivy/uix/scrollview.py +++ b/kivy/uix/scrollview.py @@ -895,9 +895,10 @@ class ScrollView(StencilView): and self.effect_x: width = self.width if touch.ud.get('in_bar_x', False): - dx = touch.dx / float(width - width * self.hbar[1]) - self.scroll_x = min(max(self.scroll_x + dx, 0.), 1.) - self._trigger_update_from_scroll() + if self.hbar[1]!=1: + dx = touch.dx / float(width - width * self.hbar[1]) + self.scroll_x = min(max(self.scroll_x + dx, 0.), 1.) + self._trigger_update_from_scroll() else: if self.scroll_type != ['bars']: self.effect_x.update(touch.x) From ce9294e567fd40450a10009df88aec772cc2ded4 Mon Sep 17 00:00:00 2001 From: Gabriel Pettier Date: Sun, 27 Sep 2020 11:40:01 +0200 Subject: [PATCH 2/2] Pep8 fix kivy/uix/scrollview.py spaces around != --- kivy/uix/scrollview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kivy/uix/scrollview.py b/kivy/uix/scrollview.py index 83cf97243..77ca88e29 100644 --- a/kivy/uix/scrollview.py +++ b/kivy/uix/scrollview.py @@ -895,7 +895,7 @@ class ScrollView(StencilView): and self.effect_x: width = self.width if touch.ud.get('in_bar_x', False): - if self.hbar[1]!=1: + if self.hbar[1] != 1: dx = touch.dx / float(width - width * self.hbar[1]) self.scroll_x = min(max(self.scroll_x + dx, 0.), 1.) self._trigger_update_from_scroll()