From c3b50239b17e20c1ae5dca874815e2cd1f06b61b Mon Sep 17 00:00:00 2001 From: TomSchimansky Date: Thu, 21 Apr 2022 18:45:51 +0200 Subject: [PATCH] fixes for Windows --- customtkinter/scaling_tracker.py | 2 +- customtkinter/widgets/ctk_canvas.py | 9 ++++----- examples/simple_example.py | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/customtkinter/scaling_tracker.py b/customtkinter/scaling_tracker.py index 851dd7e..e38544a 100644 --- a/customtkinter/scaling_tracker.py +++ b/customtkinter/scaling_tracker.py @@ -77,7 +77,7 @@ class ScalingTracker: DPI100pc = 96 # DPI 96 is 100% scaling DPI_type = 0 # MDT_EFFECTIVE_DPI = 0, MDT_ANGULAR_DPI = 1, MDT_RAW_DPI = 2 - window_hwnd = wintypes.HWND(window) + window_hwnd = wintypes.HWND(window.winfo_id()) monitor_handle = windll.user32.MonitorFromWindow(window_hwnd, wintypes.DWORD(2)) # MONITOR_DEFAULTTONEAREST = 2 x_dpi, y_dpi = wintypes.UINT(), wintypes.UINT() windll.shcore.GetDpiForMonitor(monitor_handle, DPI_type, pointer(x_dpi), pointer(y_dpi)) diff --git a/customtkinter/widgets/ctk_canvas.py b/customtkinter/widgets/ctk_canvas.py index 074f5fe..62492d6 100644 --- a/customtkinter/widgets/ctk_canvas.py +++ b/customtkinter/widgets/ctk_canvas.py @@ -12,11 +12,10 @@ class CTkCanvas(tkinter.Canvas): self.aa_circle_canvas_ids = set() def get_char_from_radius(self, radius): - if CTkSettings.scaling_factor == 1: - if radius >= 20: - return "A" - else: - return self.radius_to_char_fine[radius] + if radius >= 20: + return "A" + else: + return self.radius_to_char_fine[radius] def create_aa_circle(self, x_pos, y_pos, radius, angle=0, fill="white", tags="", anchor=tkinter.CENTER) -> str: # create a circle with a font element diff --git a/examples/simple_example.py b/examples/simple_example.py index cf9583b..08919d7 100644 --- a/examples/simple_example.py +++ b/examples/simple_example.py @@ -4,7 +4,7 @@ import customtkinter # <- import the CustomTkinter module customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light" customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue" -customtkinter.ScalingTracker.set_user_scaling(0.9) +customtkinter.ScalingTracker.set_user_scaling(1.5) root_tk = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window) root_tk.geometry("400x480")