From 58cb5a1a1d51a0f7a9ed3125b475da066fe29cf9 Mon Sep 17 00:00:00 2001 From: Huy Pham <42948410+hpham@users.noreply.github.com> Date: Mon, 2 Mar 2020 11:02:54 -0800 Subject: [PATCH] add a scrollbar next to scale entry to allow scale adjustment in increments of a specific value (since the Scale Slider widget does not support this) --- daemon/core/gui/dialogs/preferences.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/daemon/core/gui/dialogs/preferences.py b/daemon/core/gui/dialogs/preferences.py index afba6fed..45a3acee 100644 --- a/daemon/core/gui/dialogs/preferences.py +++ b/daemon/core/gui/dialogs/preferences.py @@ -11,6 +11,8 @@ from core.gui.themes import FRAME_PAD, PADX, PADY, scale_fonts if TYPE_CHECKING: from core.gui.app import Application +SCALE_INTERVAL = 0.01 + class PreferencesDialog(Dialog): def __init__(self, master: "Application", app: "Application"): @@ -90,6 +92,9 @@ class PreferencesDialog(Dialog): ) entry.grid(row=0, column=1) + scrollbar = ttk.Scrollbar(scale_frame, command=self.adjust_scale) + scrollbar.grid(row=0, column=2) + def draw_buttons(self): frame = ttk.Frame(self.top) frame.grid(sticky="ew") @@ -138,3 +143,16 @@ class PreferencesDialog(Dialog): # scale toolbar and canvas items self.app.toolbar.scale() self.app.canvas.scale_graph() + + def adjust_scale(self, arg1: str, arg2: str, arg3: str): + scale_value = self.gui_scale.get() + if arg2 == "-1": + if scale_value <= 4.9: + self.gui_scale.set(scale_value + SCALE_INTERVAL) + else: + self.gui_scale.set(5.0) + elif arg2 == "1": + if scale_value >= 0.6: + self.gui_scale.set(scale_value - SCALE_INTERVAL) + else: + self.gui_scale.set(0.5)