fixed scrollbar for Windows

This commit is contained in:
TomSchimansky
2022-06-19 22:12:19 +02:00
parent 79ecd2e946
commit 43900c7fef
4 changed files with 26 additions and 16 deletions

View File

@ -34,8 +34,8 @@
"dropdown_color": ["gray90", "gray20"],
"dropdown_hover": ["gray75", "gray28"],
"dropdown_text": ["gray10", "#DCE4EE"],
"scrollbar": ["gray75", "gray25"],
"scrollbar_hover": ["gray50", "gray40"]
"scrollbar": ["gray60", "gray38"],
"scrollbar_hover": ["gray45", "gray50"]
},
"text": {
"macOS": {
@ -73,7 +73,7 @@
"switch_corner_radius": 1000,
"switch_button_corner_radius": 1000,
"switch_button_length": 0,
"scrollbar_corner_radius": 6,
"scrollbar_corner_radius": 1000,
"scrollbar_border_spacing": 4
}
}

View File

@ -1062,16 +1062,16 @@ class DrawEngine:
else:
self._canvas.delete("scrollbar_corner_part")
if not self._canvas.find_withtag("scrollbar_rectangle_1") and width > 2 * corner_radius:
if not self._canvas.find_withtag("scrollbar_rectangle_1") and height > 2 * corner_radius:
self._canvas.create_rectangle(0, 0, 0, 0, tags=("scrollbar_rectangle_1", "scrollbar_rectangle_part", "scrollbar_parts"), width=0)
requires_recoloring = True
elif self._canvas.find_withtag("scrollbar_rectangle_1") and not width > 2 * corner_radius:
elif self._canvas.find_withtag("scrollbar_rectangle_1") and not height > 2 * corner_radius:
self._canvas.delete("scrollbar_rectangle_1")
if not self._canvas.find_withtag("scrollbar_rectangle_2"):
if not self._canvas.find_withtag("scrollbar_rectangle_2") and width > 2 * corner_radius:
self._canvas.create_rectangle(0, 0, 0, 0, tags=("scrollbar_rectangle_2", "scrollbar_rectangle_part", "scrollbar_parts"), width=0)
requires_recoloring = True
elif self._canvas.find_withtag("scrollbar_rectangle_2") and not height > 2 * corner_radius:
elif self._canvas.find_withtag("scrollbar_rectangle_2") and not width > 2 * corner_radius:
self._canvas.delete("scrollbar_rectangle_2")
self._canvas.coords("scrollbar_rectangle_1",

View File

@ -1,3 +1,5 @@
import sys
from .ctk_canvas import CTkCanvas
from ..theme_manager import ThemeManager
from ..draw_engine import DrawEngine
@ -196,5 +198,8 @@ class CTkScrollbar(CTkBaseClass):
def mouse_scroll_event(self, event=None):
if self.command is not None:
self.command('scroll', event.delta, 'units')
if sys.platform.startswith("win"):
self.command('scroll', -int(event.delta/40), 'units')
else:
self.command('scroll', -event.delta, 'units')