From afeae9fa80f8b6fd53140181c6cf94ffa2be2bed Mon Sep 17 00:00:00 2001 From: thiswillbeyourgithub Date: Mon, 28 Feb 2022 11:05:12 +0100 Subject: [PATCH] new: add increment size argument in Spinner widgets Signed-off-by: thiswillbeyourgithub --- wasp/widgets.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wasp/widgets.py b/wasp/widgets.py index 4e63d95..556c7f5 100644 --- a/wasp/widgets.py +++ b/wasp/widgets.py @@ -438,8 +438,8 @@ class Spinner(): In order to have large enough hit boxes the spinner is a fairly large widget and requires 60x120 px. """ - def __init__(self, x, y, mn, mx, field=1): - self._im = bytes((x, y, mn, mx, field)) + def __init__(self, x, y, mn, mx, field=1, incr=1): + self._im = bytes((x, y, mn, mx, field, incr)) self.value = mn def draw(self): @@ -468,13 +468,15 @@ class Spinner(): im = self._im if x >= im[0] and x < im[0]+60 and y >= im[1] and y < im[1]+120: if y < im[1] + 60: - self.value += 1 + self.value += im[5] if self.value > im[3]: self.value = im[2] else: - self.value -= 1 + self.value -= im[5] if self.value < im[2]: self.value = im[3] + while self.value % im[5] != 0: + self.value -= 1 self.update() return True