mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
fixed scrollbar for Windows
This commit is contained in:
parent
79ecd2e946
commit
43900c7fef
@ -34,8 +34,8 @@
|
|||||||
"dropdown_color": ["gray90", "gray20"],
|
"dropdown_color": ["gray90", "gray20"],
|
||||||
"dropdown_hover": ["gray75", "gray28"],
|
"dropdown_hover": ["gray75", "gray28"],
|
||||||
"dropdown_text": ["gray10", "#DCE4EE"],
|
"dropdown_text": ["gray10", "#DCE4EE"],
|
||||||
"scrollbar": ["gray75", "gray25"],
|
"scrollbar": ["gray60", "gray38"],
|
||||||
"scrollbar_hover": ["gray50", "gray40"]
|
"scrollbar_hover": ["gray45", "gray50"]
|
||||||
},
|
},
|
||||||
"text": {
|
"text": {
|
||||||
"macOS": {
|
"macOS": {
|
||||||
@ -73,7 +73,7 @@
|
|||||||
"switch_corner_radius": 1000,
|
"switch_corner_radius": 1000,
|
||||||
"switch_button_corner_radius": 1000,
|
"switch_button_corner_radius": 1000,
|
||||||
"switch_button_length": 0,
|
"switch_button_length": 0,
|
||||||
"scrollbar_corner_radius": 6,
|
"scrollbar_corner_radius": 1000,
|
||||||
"scrollbar_border_spacing": 4
|
"scrollbar_border_spacing": 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1062,16 +1062,16 @@ class DrawEngine:
|
|||||||
else:
|
else:
|
||||||
self._canvas.delete("scrollbar_corner_part")
|
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)
|
self._canvas.create_rectangle(0, 0, 0, 0, tags=("scrollbar_rectangle_1", "scrollbar_rectangle_part", "scrollbar_parts"), width=0)
|
||||||
requires_recoloring = True
|
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")
|
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)
|
self._canvas.create_rectangle(0, 0, 0, 0, tags=("scrollbar_rectangle_2", "scrollbar_rectangle_part", "scrollbar_parts"), width=0)
|
||||||
requires_recoloring = True
|
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.delete("scrollbar_rectangle_2")
|
||||||
|
|
||||||
self._canvas.coords("scrollbar_rectangle_1",
|
self._canvas.coords("scrollbar_rectangle_1",
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
from .ctk_canvas import CTkCanvas
|
from .ctk_canvas import CTkCanvas
|
||||||
from ..theme_manager import ThemeManager
|
from ..theme_manager import ThemeManager
|
||||||
from ..draw_engine import DrawEngine
|
from ..draw_engine import DrawEngine
|
||||||
@ -196,5 +198,8 @@ class CTkScrollbar(CTkBaseClass):
|
|||||||
|
|
||||||
def mouse_scroll_event(self, event=None):
|
def mouse_scroll_event(self, event=None):
|
||||||
if self.command is not 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')
|
||||||
|
|
||||||
|
@ -2,19 +2,24 @@ import tkinter
|
|||||||
import customtkinter
|
import customtkinter
|
||||||
|
|
||||||
# customtkinter.DrawEngine.preferred_drawing_method = "font_shapes"
|
# customtkinter.DrawEngine.preferred_drawing_method = "font_shapes"
|
||||||
|
#customtkinter.set_widget_scaling(2)
|
||||||
|
#customtkinter.set_window_scaling(2)
|
||||||
|
#customtkinter.set_spacing_scaling(2)
|
||||||
|
|
||||||
|
customtkinter.set_appearance_mode("light")
|
||||||
|
|
||||||
|
|
||||||
def to_scollbar(*args, **kwargs):
|
def to_scollbar(*args, **kwargs):
|
||||||
tk_textbox_scrollbar.set(*args, **kwargs)
|
#tk_textbox_scrollbar.set(*args, **kwargs)
|
||||||
ctk_textbox_scrollbar.set(*args, **kwargs)
|
ctk_textbox_scrollbar.set(*args, **kwargs)
|
||||||
ctk_textbox_scrollbar.update_idletasks()
|
ctk_textbox_scrollbar.update_idletasks()
|
||||||
tk_textbox_scrollbar.update_idletasks()
|
#tk_textbox_scrollbar.update_idletasks()
|
||||||
print("to_scollbar:", args, **kwargs)
|
#print(*args)
|
||||||
|
|
||||||
|
|
||||||
def from_scrollbar(*args, **kwargs):
|
def from_scrollbar(*args, **kwargs):
|
||||||
tk_textbox.yview(*args, **kwargs)
|
tk_textbox.yview(*args, **kwargs)
|
||||||
print("from_scrollbar:", args, **kwargs)
|
#print(*args)
|
||||||
|
|
||||||
|
|
||||||
app = customtkinter.CTk()
|
app = customtkinter.CTk()
|
||||||
@ -22,13 +27,13 @@ app.grid_rowconfigure(0, weight=1)
|
|||||||
app.grid_columnconfigure(0, weight=1)
|
app.grid_columnconfigure(0, weight=1)
|
||||||
|
|
||||||
tk_textbox = tkinter.Text(app)
|
tk_textbox = tkinter.Text(app)
|
||||||
tk_textbox.grid(row=0, column=0, sticky="nsew")
|
tk_textbox.grid(row=0, column=0, sticky="ns")
|
||||||
|
|
||||||
ctk_textbox_scrollbar = customtkinter.CTkScrollbar(app, command=from_scrollbar, fg_color="red")
|
ctk_textbox_scrollbar = customtkinter.CTkScrollbar(app, command=from_scrollbar)
|
||||||
ctk_textbox_scrollbar.grid(row=0, column=1, padx=0, sticky="ns")
|
ctk_textbox_scrollbar.grid(row=0, column=1, padx=0, sticky="ns")
|
||||||
|
|
||||||
tk_textbox_scrollbar = tkinter.Scrollbar(app, command=from_scrollbar)
|
#tk_textbox_scrollbar = tkinter.Scrollbar(app, command=from_scrollbar)
|
||||||
tk_textbox_scrollbar.grid(row=0, column=2, padx=1, sticky="ns")
|
#tk_textbox_scrollbar.grid(row=0, column=2, padx=1, sticky="ns")
|
||||||
|
|
||||||
tk_textbox.configure(yscrollcommand=to_scollbar)
|
tk_textbox.configure(yscrollcommand=to_scollbar)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user