From 4fbcce75a00ac5499c59115f3e134d234e40de5e Mon Sep 17 00:00:00 2001 From: Ripe <42308266+Ripeey@users.noreply.github.com> Date: Sun, 10 Jul 2022 23:19:14 +0530 Subject: [PATCH 01/18] Update dark-blue.json --- customtkinter/assets/themes/dark-blue.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/customtkinter/assets/themes/dark-blue.json b/customtkinter/assets/themes/dark-blue.json index 2868ec4..0b1a33f 100644 --- a/customtkinter/assets/themes/dark-blue.json +++ b/customtkinter/assets/themes/dark-blue.json @@ -72,6 +72,8 @@ "switch_border_width": 3, "switch_corner_radius": 1000, "switch_button_corner_radius": 1000, - "switch_button_length": 0 + "switch_button_length": 0, + "scrollbar_corner_radius": 1000, + "scrollbar_border_spacing": 4 } } From d45904b1e40dba4392b38fab8fab6ff3db8ffe24 Mon Sep 17 00:00:00 2001 From: Ripeey Date: Mon, 11 Jul 2022 04:57:17 +0530 Subject: [PATCH 02/18] Update missing scrollbar configs in green and sweetkind themes. --- customtkinter/assets/themes/green.json | 4 +++- customtkinter/assets/themes/sweetkind.json | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/customtkinter/assets/themes/green.json b/customtkinter/assets/themes/green.json index a6608a1..d3e9442 100644 --- a/customtkinter/assets/themes/green.json +++ b/customtkinter/assets/themes/green.json @@ -72,6 +72,8 @@ "switch_border_width": 3, "switch_corner_radius": 1000, "switch_button_corner_radius": 1000, - "switch_button_length": 0 + "switch_button_length": 0, + "scrollbar_corner_radius": 1000, + "scrollbar_border_spacing": 4 } } diff --git a/customtkinter/assets/themes/sweetkind.json b/customtkinter/assets/themes/sweetkind.json index f9bec05..1756db5 100644 --- a/customtkinter/assets/themes/sweetkind.json +++ b/customtkinter/assets/themes/sweetkind.json @@ -72,6 +72,8 @@ "switch_border_width": 3, "switch_corner_radius": 1000, "switch_button_corner_radius": 1000, - "switch_button_length": 2 + "switch_button_length": 2, + "scrollbar_corner_radius": 1000, + "scrollbar_border_spacing": 4 } } From acaeceb96d5f9df9b678b4f9b0c1d5778aceea43 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Tue, 12 Jul 2022 21:52:52 +0200 Subject: [PATCH 03/18] added methods to CTkTextbox --- customtkinter/widgets/ctk_button.py | 4 +- customtkinter/widgets/ctk_label.py | 5 ++ customtkinter/widgets/ctk_textbox.py | 48 +++++++++++-------- examples/simple_example.py | 1 + .../complex_example_new.py | 10 ++-- 5 files changed, 44 insertions(+), 24 deletions(-) diff --git a/customtkinter/widgets/ctk_button.py b/customtkinter/widgets/ctk_button.py index e8f8abd..5e6867e 100644 --- a/customtkinter/widgets/ctk_button.py +++ b/customtkinter/widgets/ctk_button.py @@ -1,6 +1,6 @@ import tkinter import sys -from typing import Union, Tuple, Callable, Literal +from typing import Union, Tuple, Callable from .ctk_canvas import CTkCanvas from ..theme_manager import ThemeManager @@ -250,7 +250,7 @@ class CTkButton(CTkBaseClass): if "image" in kwargs: self.image = kwargs.pop("image") - self.set_image(self.image) + require_redraw = True if "compound" in kwargs: self.compound = kwargs.pop("compound") diff --git a/customtkinter/widgets/ctk_label.py b/customtkinter/widgets/ctk_label.py index ec3cfbc..033841d 100644 --- a/customtkinter/widgets/ctk_label.py +++ b/customtkinter/widgets/ctk_label.py @@ -1,3 +1,4 @@ +import sys import tkinter from .ctk_canvas import CTkCanvas @@ -106,6 +107,10 @@ class CTkLabel(CTkBaseClass): self.canvas.configure(bg=ThemeManager.single_color(self.bg_color, self._appearance_mode)) + def config(self, **kwargs): + sys.stderr.write("Warning: Use .configure() instead of .config()") + self.configure(**kwargs) + def configure(self, require_redraw=False, **kwargs): if "anchor" in kwargs: self.anchor = kwargs.pop("anchor") diff --git a/customtkinter/widgets/ctk_textbox.py b/customtkinter/widgets/ctk_textbox.py index bd34842..9b40332 100644 --- a/customtkinter/widgets/ctk_textbox.py +++ b/customtkinter/widgets/ctk_textbox.py @@ -28,12 +28,13 @@ class CTkTextbox(CTkBaseClass): # color self.fg_color = ThemeManager.theme["color"]["entry"] if fg_color == "default_theme" else fg_color self.border_color = ThemeManager.theme["color"]["frame_border"] if border_color == "default_theme" else border_color + self.text_color = ThemeManager.theme["color"]["text"] if text_color == "default_theme" else text_color # shape self.corner_radius = ThemeManager.theme["shape"]["frame_corner_radius"] if corner_radius == "default_theme" else corner_radius self.border_width = ThemeManager.theme["shape"]["frame_border_width"] if border_width == "default_theme" else border_width - self.text_color = ThemeManager.theme["color"]["text"] if text_color == "default_theme" else text_color + # text self.text_font = (ThemeManager.theme["text"]["font"], ThemeManager.theme["text"]["size"]) if text_font == "default_theme" else text_font # configure 1x1 grid @@ -56,28 +57,18 @@ class CTkTextbox(CTkBaseClass): height=0, font=self.text_font, highlightthickness=0, + insertbackground=ThemeManager.single_color(("black", "white"), self._appearance_mode), bg=ThemeManager.single_color(self.fg_color, self._appearance_mode), **kwargs) self.textbox.grid(row=0, column=0, padx=self.corner_radius, pady=self.corner_radius, rowspan=1, columnspan=1, sticky="nsew") self.bind('', self.update_dimensions_event) - self.draw() - def winfo_children(self): - """ winfo_children of CTkFrame without self.canvas widget, - because it's not a child but part of the CTkFrame itself """ - - child_widgets = super().winfo_children() - try: - child_widgets.remove(self.canvas) - return child_widgets - except ValueError: - return child_widgets - def set_scaling(self, *args, **kwargs): super().set_scaling(*args, **kwargs) + self.textbox.configure(font=self.apply_font_scaling(self.text_font)) self.canvas.configure(width=self.apply_widget_scaling(self._desired_width), height=self.apply_widget_scaling(self._desired_height)) self.draw() @@ -110,17 +101,36 @@ class CTkTextbox(CTkBaseClass): outline=ThemeManager.single_color(self.border_color, self._appearance_mode)) self.canvas.configure(bg=ThemeManager.single_color(self.bg_color, self._appearance_mode)) + self.textbox.configure(fg=ThemeManager.single_color(self.text_color, self._appearance_mode), + bg=ThemeManager.single_color(self.fg_color, self._appearance_mode), + insertbackground=ThemeManager.single_color(("black", "white"), self._appearance_mode)) + self.canvas.tag_lower("inner_parts") self.canvas.tag_lower("border_parts") - def yview(self, args, kwargs): - self.textbox.yview(args, kwargs) + def yview(self, *args): + return self.textbox.yview(*args) - def xview(self, args, kwargs): - self.textbox.xview(args, kwargs) + def xview(self, *args): + return self.textbox.xview(*args) - def insert(self, args, kwargs): - self.textbox.insert(args, kwargs) + def insert(self, *args, **kwargs): + return self.textbox.insert(*args, **kwargs) + + def focus(self): + return self.textbox.focus() + + def tag_add(self, *args, **kwargs): + return self.textbox.tag_add(*args, **kwargs) + + def tag_config(self, *args, **kwargs): + return self.textbox.tag_config(*args, **kwargs) + + def tag_configure(self, *args, **kwargs): + return self.textbox.tag_configure(*args, **kwargs) + + def tag_remove(self, *args, **kwargs): + return self.textbox.tag_remove(*args, **kwargs) def configure(self, require_redraw=False, **kwargs): if "fg_color" in kwargs: diff --git a/examples/simple_example.py b/examples/simple_example.py index 370b4f4..31d916e 100644 --- a/examples/simple_example.py +++ b/examples/simple_example.py @@ -28,6 +28,7 @@ progressbar_1.pack(pady=12, padx=10) button_1 = customtkinter.CTkButton(master=frame_1, command=button_callback) button_1.pack(pady=12, padx=10) +button_1.configure(state='disabled') slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_callback, from_=0, to=1) slider_1.pack(pady=12, padx=10) diff --git a/test/manual_integration_tests/complex_example_new.py b/test/manual_integration_tests/complex_example_new.py index adff63c..20064b3 100644 --- a/test/manual_integration_tests/complex_example_new.py +++ b/test/manual_integration_tests/complex_example_new.py @@ -39,7 +39,7 @@ class App(customtkinter.CTk): self.appearance_mode_optionemenu.grid(row=6, column=0, padx=20, pady=(10, 10)) self.scaling_label = customtkinter.CTkLabel(self.sidebar_frame, text="Widget Scaling:", anchor="w") self.scaling_label.grid(row=7, column=0, padx=20, pady=(10, 0)) - self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["75%", "100%", "150%"], + self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["90%", "100%", "110%"], command=self.change_scaling) self.scaling_optionemenu.grid(row=8, column=0, padx=20, pady=(10, 20)) @@ -50,8 +50,8 @@ class App(customtkinter.CTk): self.main_button_1 = customtkinter.CTkButton(self, fg_color=None, border_width=2) self.main_button_1.grid(row=3, column=3, padx=(10, 20), pady=(10, 20), sticky="nsew") - self.text_frame = customtkinter.CTkFrame(self) - self.text_frame.grid(row=0, column=1, padx=(20, 10), pady=(20, 10), sticky="nsew") + self.textbox = customtkinter.CTkTextbox(self) + self.textbox.grid(row=0, column=1, padx=(20, 10), pady=(20, 10), sticky="nsew") # create radiobutton frame self.radiobutton_frame = customtkinter.CTkFrame(self) @@ -119,6 +119,10 @@ class App(customtkinter.CTk): self.scaling_optionemenu.set("100%") self.optionmenu_1.set("CTkOptionmenu") self.combobox_1.set("CTkComboBox") + self.textbox.insert("1.0", + "CTkTextbox\n\nLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.", ) + #self.textbox.tag_add("headline", "1.0", "1.end") + #self.textbox.tag_config("headline", foreground="red") def open_input_dialog(self): dialog = customtkinter.CTkInputDialog(master=None, text="Type in a number:", title="CTkInputDialog") From db4f5ec9198f227461a94d9e4453c3f1871eda8e Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Tue, 12 Jul 2022 21:57:50 +0200 Subject: [PATCH 04/18] Bump to 4.5.5 --- customtkinter/__init__.py | 2 +- pyproject.toml | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/customtkinter/__init__.py b/customtkinter/__init__.py index 0f4100c..3432be8 100644 --- a/customtkinter/__init__.py +++ b/customtkinter/__init__.py @@ -1,4 +1,4 @@ -__version__ = "4.5.4" +__version__ = "4.5.5" import os import sys diff --git a/pyproject.toml b/pyproject.toml index 5a4ee4e..f67f8e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" github_url = "https://github.com/TomSchimansky/CustomTkinter" [tool.tbump.version] -current = "4.5.4" +current = "4.5.5" # Example of a semver regexp. # Make sure this matches current_version before diff --git a/setup.cfg b/setup.cfg index 36442c4..c299a57 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = customtkinter -version = 4.5.4 +version = 4.5.5 description = Create modern looking GUIs with Python long_description = CustomTkinter UI-Library\n\n[](https://github.com/TomSchimansky/CustomTkinter/blob/master/documentation_images/Windows_dark.png)\n\nMore Information: https://github.com/TomSchimansky/CustomTkinter long_description_content_type = text/markdown From 6a43dfd9bff45a425894ad265b439923c4dab981 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Thu, 14 Jul 2022 13:57:02 +0200 Subject: [PATCH 05/18] added corner_radius to .configure() of CTkButton --- customtkinter/widgets/ctk_button.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/customtkinter/widgets/ctk_button.py b/customtkinter/widgets/ctk_button.py index 5e6867e..0e8cfb9 100644 --- a/customtkinter/widgets/ctk_button.py +++ b/customtkinter/widgets/ctk_button.py @@ -252,6 +252,10 @@ class CTkButton(CTkBaseClass): self.image = kwargs.pop("image") require_redraw = True + if "corner_radius" in kwargs: + self.corner_radius = kwargs.pop("corner_radius") + require_redraw = True + if "compound" in kwargs: self.compound = kwargs.pop("compound") require_redraw = True From d9ff3d998c9210e6900250fe260158a1dca6a5d7 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sun, 17 Jul 2022 20:34:54 +0200 Subject: [PATCH 06/18] fixed command function bug in CTkSwitch --- customtkinter/widgets/ctk_switch.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/customtkinter/widgets/ctk_switch.py b/customtkinter/widgets/ctk_switch.py index de64448..f1de210 100644 --- a/customtkinter/widgets/ctk_switch.py +++ b/customtkinter/widgets/ctk_switch.py @@ -104,13 +104,13 @@ class CTkSwitch(CTkBaseClass): self.text_label.bind("", self.on_leave) self.text_label.bind("", self.toggle) - self.draw() # initial draw - self.set_cursor() - if self.variable is not None and self.variable != "": self.variable_callback_name = self.variable.trace_add("write", self.variable_callback) self.check_state = True if self.variable.get() == self.onvalue else False + self.draw() # initial draw + self.set_cursor() + def set_scaling(self, *args, **kwargs): super().set_scaling(*args, **kwargs) @@ -209,14 +209,14 @@ class CTkSwitch(CTkBaseClass): self.draw(no_color_updates=True) - if self.command is not None: - self.command() - if self.variable is not None: self.variable_callback_blocked = True self.variable.set(self.onvalue if self.check_state is True else self.offvalue) self.variable_callback_blocked = False + if self.command is not None: + self.command() + def select(self, from_variable_callback=False): if self.state is not tkinter.DISABLED or from_variable_callback: self.check_state = True From 228729305bc164c6f8b71f5a275841d5ede16111 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sun, 17 Jul 2022 20:35:12 +0200 Subject: [PATCH 07/18] Bump to 4.5.6 --- customtkinter/__init__.py | 2 +- pyproject.toml | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/customtkinter/__init__.py b/customtkinter/__init__.py index 3432be8..1f87632 100644 --- a/customtkinter/__init__.py +++ b/customtkinter/__init__.py @@ -1,4 +1,4 @@ -__version__ = "4.5.5" +__version__ = "4.5.6" import os import sys diff --git a/pyproject.toml b/pyproject.toml index f67f8e8..32aefe7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" github_url = "https://github.com/TomSchimansky/CustomTkinter" [tool.tbump.version] -current = "4.5.5" +current = "4.5.6" # Example of a semver regexp. # Make sure this matches current_version before diff --git a/setup.cfg b/setup.cfg index c299a57..48e0036 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = customtkinter -version = 4.5.5 +version = 4.5.6 description = Create modern looking GUIs with Python long_description = CustomTkinter UI-Library\n\n[](https://github.com/TomSchimansky/CustomTkinter/blob/master/documentation_images/Windows_dark.png)\n\nMore Information: https://github.com/TomSchimansky/CustomTkinter long_description_content_type = text/markdown From b3c03889580c31f96cca425871e235aa78e4d522 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sun, 17 Jul 2022 20:37:24 +0200 Subject: [PATCH 08/18] added corner radius to CTkLabel in complex_example.py --- examples/complex_example.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/complex_example.py b/examples/complex_example.py index 2a5c088..199741a 100644 --- a/examples/complex_example.py +++ b/examples/complex_example.py @@ -90,6 +90,7 @@ class App(customtkinter.CTk): "amet consetetur sadipscing elitr,\n" + "sed diam nonumy eirmod tempor" , height=100, + corner_radius=6, # <- custom corner radius fg_color=("white", "gray38"), # <- custom tuple-color justify=tkinter.LEFT) self.label_info_1.grid(column=0, row=0, sticky="nwe", padx=15, pady=15) From 67f2072e0759dac95f9908ee8ec0954f1d5ec85b Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sun, 17 Jul 2022 21:41:13 +0200 Subject: [PATCH 09/18] added return value of geometry method for CTk and CTkToplevel --- customtkinter/windows/ctk_tk.py | 40 ++++++++++++++++++---- customtkinter/windows/ctk_toplevel.py | 49 +++++++++++++++++---------- 2 files changed, 65 insertions(+), 24 deletions(-) diff --git a/customtkinter/windows/ctk_tk.py b/customtkinter/windows/ctk_tk.py index b561751..7cbfedf 100644 --- a/customtkinter/windows/ctk_tk.py +++ b/customtkinter/windows/ctk_tk.py @@ -129,16 +129,42 @@ class CTk(tkinter.Tk): if self.current_height > height: self.current_height = height super().maxsize(self.apply_window_scaling(self.max_width), self.apply_window_scaling(self.max_height)) - def geometry(self, geometry_string): - super().geometry(self.apply_geometry_scaling(geometry_string)) + def geometry(self, geometry_string: str = None): + if geometry_string is not None: + super().geometry(self.apply_geometry_scaling(geometry_string)) - # update width and height attributes - numbers = list(map(int, re.split(r"[x+]", geometry_string))) # split geometry string into list of numbers - self.current_width = max(self.min_width, min(numbers[0], self.max_width)) # bound value between min and max - self.current_height = max(self.min_height, min(numbers[1], self.max_height)) + # update width and height attributes + numbers = list(map(int, re.split(r"[x+-]", geometry_string))) # split geometry string into list of numbers + self.current_width = max(self.min_width, min(numbers[0], self.max_width)) # bound value between min and max + self.current_height = max(self.min_height, min(numbers[1], self.max_height)) + else: + return self.reverse_geometry_scaling(super().geometry()) def apply_geometry_scaling(self, geometry_string): - return re.sub(re.compile("\d+"), lambda match_obj: str(round(int(match_obj.group(0)) * self.window_scaling)), geometry_string) + value_list = re.split(r"[x+-]", geometry_string) + separator_list = re.split(r"\d+", geometry_string) + + if len(value_list) == 2: + scaled_width = str(round(int(value_list[0]) * self.window_scaling)) + scaled_height = str(round(int(value_list[1]) * self.window_scaling)) + return f"{scaled_width}x{scaled_height}" + elif len(value_list) == 4: + scaled_width = str(round(int(value_list[0]) * self.window_scaling)) + scaled_height = str(round(int(value_list[1]) * self.window_scaling)) + return f"{scaled_width}x{scaled_height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" + + def reverse_geometry_scaling(self, scaled_geometry_string): + value_list = re.split(r"[x+-]", scaled_geometry_string) + separator_list = re.split(r"\d+", scaled_geometry_string) + + if len(value_list) == 2: + width = str(round(int(value_list[0]) / self.window_scaling)) + height = str(round(int(value_list[1]) / self.window_scaling)) + return f"{width}x{height}" + elif len(value_list) == 4: + width = str(round(int(value_list[0]) / self.window_scaling)) + height = str(round(int(value_list[1]) / self.window_scaling)) + return f"{width}x{height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" def apply_window_scaling(self, value): if isinstance(value, (int, float)): diff --git a/customtkinter/windows/ctk_toplevel.py b/customtkinter/windows/ctk_toplevel.py index b8c853c..10adbbc 100644 --- a/customtkinter/windows/ctk_toplevel.py +++ b/customtkinter/windows/ctk_toplevel.py @@ -84,18 +84,30 @@ class CTkToplevel(tkinter.Toplevel): super().maxsize(self.apply_window_scaling(self.max_width), self.apply_window_scaling(self.max_height)) def apply_geometry_scaling(self, geometry_string): - numbers = list(map(int, re.split(r"[x+]", geometry_string))) # split geometry string into list of numbers + value_list = re.split(r"[x+-]", geometry_string) + separator_list = re.split(r"\d+", geometry_string) - if len(numbers) == 2: - return f"{self.apply_window_scaling(numbers[0]):.0f}x" +\ - f"{self.apply_window_scaling(numbers[1]):.0f}" - elif len(numbers) == 4: - return f"{self.apply_window_scaling(numbers[0]):.0f}x" +\ - f"{self.apply_window_scaling(numbers[1]):.0f}+" +\ - f"{self.apply_window_scaling(numbers[2]):.0f}+" +\ - f"{self.apply_window_scaling(numbers[3]):.0f}" - else: - return geometry_string + if len(value_list) == 2: + scaled_width = str(round(int(value_list[0]) * self.window_scaling)) + scaled_height = str(round(int(value_list[1]) * self.window_scaling)) + return f"{scaled_width}x{scaled_height}" + elif len(value_list) == 4: + scaled_width = str(round(int(value_list[0]) * self.window_scaling)) + scaled_height = str(round(int(value_list[1]) * self.window_scaling)) + return f"{scaled_width}x{scaled_height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" + + def reverse_geometry_scaling(self, scaled_geometry_string): + value_list = re.split(r"[x+-]", scaled_geometry_string) + separator_list = re.split(r"\d+", scaled_geometry_string) + + if len(value_list) == 2: + width = str(round(int(value_list[0]) / self.window_scaling)) + height = str(round(int(value_list[1]) / self.window_scaling)) + return f"{width}x{height}" + elif len(value_list) == 4: + width = str(round(int(value_list[0]) / self.window_scaling)) + height = str(round(int(value_list[1]) / self.window_scaling)) + return f"{width}x{height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" def apply_window_scaling(self, value): if isinstance(value, (int, float)): @@ -103,13 +115,16 @@ class CTkToplevel(tkinter.Toplevel): else: return value - def geometry(self, geometry_string): - super().geometry(self.apply_geometry_scaling(geometry_string)) + def geometry(self, geometry_string: str = None): + if geometry_string is not None: + super().geometry(self.apply_geometry_scaling(geometry_string)) - # update width and height attributes - numbers = list(map(int, re.split(r"[x+]", geometry_string))) # split geometry string into list of numbers - self.current_width = max(self.min_width, min(numbers[0], self.max_width)) # bound value between min and max - self.current_height = max(self.min_height, min(numbers[1], self.max_height)) + # update width and height attributes + numbers = list(map(int, re.split(r"[x+]", geometry_string))) # split geometry string into list of numbers + self.current_width = max(self.min_width, min(numbers[0], self.max_width)) # bound value between min and max + self.current_height = max(self.min_height, min(numbers[1], self.max_height)) + else: + return self.reverse_geometry_scaling(super().geometry()) def destroy(self): AppearanceModeTracker.remove(self.set_appearance_mode) From 6bfddda399cb7c1fb747a751a633e21b5ce0c0e7 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sun, 17 Jul 2022 21:41:28 +0200 Subject: [PATCH 10/18] Bump to 4.5.7 --- customtkinter/__init__.py | 2 +- pyproject.toml | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/customtkinter/__init__.py b/customtkinter/__init__.py index 1f87632..0dc9ab6 100644 --- a/customtkinter/__init__.py +++ b/customtkinter/__init__.py @@ -1,4 +1,4 @@ -__version__ = "4.5.6" +__version__ = "4.5.7" import os import sys diff --git a/pyproject.toml b/pyproject.toml index 32aefe7..48d3b40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" github_url = "https://github.com/TomSchimansky/CustomTkinter" [tool.tbump.version] -current = "4.5.6" +current = "4.5.7" # Example of a semver regexp. # Make sure this matches current_version before diff --git a/setup.cfg b/setup.cfg index 48e0036..750de9e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = customtkinter -version = 4.5.6 +version = 4.5.7 description = Create modern looking GUIs with Python long_description = CustomTkinter UI-Library\n\n[](https://github.com/TomSchimansky/CustomTkinter/blob/master/documentation_images/Windows_dark.png)\n\nMore Information: https://github.com/TomSchimansky/CustomTkinter long_description_content_type = text/markdown From ddd49377d49401955328612453580585d0ec42af Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sun, 17 Jul 2022 21:45:29 +0200 Subject: [PATCH 11/18] fixed geomtry method for CTk and CTkToplevel --- customtkinter/windows/ctk_tk.py | 5 +++-- customtkinter/windows/ctk_toplevel.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/customtkinter/windows/ctk_tk.py b/customtkinter/windows/ctk_tk.py index 7cbfedf..d19f5be 100644 --- a/customtkinter/windows/ctk_tk.py +++ b/customtkinter/windows/ctk_tk.py @@ -143,6 +143,7 @@ class CTk(tkinter.Tk): def apply_geometry_scaling(self, geometry_string): value_list = re.split(r"[x+-]", geometry_string) separator_list = re.split(r"\d+", geometry_string) + print(separator_list) if len(value_list) == 2: scaled_width = str(round(int(value_list[0]) * self.window_scaling)) @@ -151,7 +152,7 @@ class CTk(tkinter.Tk): elif len(value_list) == 4: scaled_width = str(round(int(value_list[0]) * self.window_scaling)) scaled_height = str(round(int(value_list[1]) * self.window_scaling)) - return f"{scaled_width}x{scaled_height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" + return f"{scaled_width}x{scaled_height}{separator_list[2]}{value_list[2]}{separator_list[3]}{value_list[3]}" def reverse_geometry_scaling(self, scaled_geometry_string): value_list = re.split(r"[x+-]", scaled_geometry_string) @@ -164,7 +165,7 @@ class CTk(tkinter.Tk): elif len(value_list) == 4: width = str(round(int(value_list[0]) / self.window_scaling)) height = str(round(int(value_list[1]) / self.window_scaling)) - return f"{width}x{height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" + return f"{width}x{height}{separator_list[2]}{value_list[2]}{separator_list[3]}{value_list[3]}" def apply_window_scaling(self, value): if isinstance(value, (int, float)): diff --git a/customtkinter/windows/ctk_toplevel.py b/customtkinter/windows/ctk_toplevel.py index 10adbbc..3b7e9fd 100644 --- a/customtkinter/windows/ctk_toplevel.py +++ b/customtkinter/windows/ctk_toplevel.py @@ -94,7 +94,7 @@ class CTkToplevel(tkinter.Toplevel): elif len(value_list) == 4: scaled_width = str(round(int(value_list[0]) * self.window_scaling)) scaled_height = str(round(int(value_list[1]) * self.window_scaling)) - return f"{scaled_width}x{scaled_height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" + return f"{scaled_width}x{scaled_height}{separator_list[2]}{value_list[2]}{separator_list[3]}{value_list[3]}" def reverse_geometry_scaling(self, scaled_geometry_string): value_list = re.split(r"[x+-]", scaled_geometry_string) @@ -107,7 +107,7 @@ class CTkToplevel(tkinter.Toplevel): elif len(value_list) == 4: width = str(round(int(value_list[0]) / self.window_scaling)) height = str(round(int(value_list[1]) / self.window_scaling)) - return f"{width}x{height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" + return f"{width}x{height}{separator_list[2]}{value_list[2]}{separator_list[3]}{value_list[3]}" def apply_window_scaling(self, value): if isinstance(value, (int, float)): From 1a57294ae92d10f0ede3ec430ce8ba8eee741f4b Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sun, 17 Jul 2022 21:45:45 +0200 Subject: [PATCH 12/18] Bump to 4.5.8 --- customtkinter/__init__.py | 2 +- pyproject.toml | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/customtkinter/__init__.py b/customtkinter/__init__.py index 0dc9ab6..85caa49 100644 --- a/customtkinter/__init__.py +++ b/customtkinter/__init__.py @@ -1,4 +1,4 @@ -__version__ = "4.5.7" +__version__ = "4.5.8" import os import sys diff --git a/pyproject.toml b/pyproject.toml index 48d3b40..fc315ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" github_url = "https://github.com/TomSchimansky/CustomTkinter" [tool.tbump.version] -current = "4.5.7" +current = "4.5.8" # Example of a semver regexp. # Make sure this matches current_version before diff --git a/setup.cfg b/setup.cfg index 750de9e..27dee96 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = customtkinter -version = 4.5.7 +version = 4.5.8 description = Create modern looking GUIs with Python long_description = CustomTkinter UI-Library\n\n[](https://github.com/TomSchimansky/CustomTkinter/blob/master/documentation_images/Windows_dark.png)\n\nMore Information: https://github.com/TomSchimansky/CustomTkinter long_description_content_type = text/markdown From ac6fb661a41f9654b509ef774f0932e06af63932 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Mon, 18 Jul 2022 12:34:27 +0200 Subject: [PATCH 13/18] removed print from CTk --- customtkinter/windows/ctk_tk.py | 1 - 1 file changed, 1 deletion(-) diff --git a/customtkinter/windows/ctk_tk.py b/customtkinter/windows/ctk_tk.py index d19f5be..b1a701d 100644 --- a/customtkinter/windows/ctk_tk.py +++ b/customtkinter/windows/ctk_tk.py @@ -143,7 +143,6 @@ class CTk(tkinter.Tk): def apply_geometry_scaling(self, geometry_string): value_list = re.split(r"[x+-]", geometry_string) separator_list = re.split(r"\d+", geometry_string) - print(separator_list) if len(value_list) == 2: scaled_width = str(round(int(value_list[0]) * self.window_scaling)) From 3bee19f8cec5c7d706c462cd238ff7a916d61d3c Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Mon, 18 Jul 2022 12:34:43 +0200 Subject: [PATCH 14/18] Bump to 4.5.9 --- customtkinter/__init__.py | 2 +- pyproject.toml | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/customtkinter/__init__.py b/customtkinter/__init__.py index 85caa49..c9d233c 100644 --- a/customtkinter/__init__.py +++ b/customtkinter/__init__.py @@ -1,4 +1,4 @@ -__version__ = "4.5.8" +__version__ = "4.5.9" import os import sys diff --git a/pyproject.toml b/pyproject.toml index fc315ed..86042bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" github_url = "https://github.com/TomSchimansky/CustomTkinter" [tool.tbump.version] -current = "4.5.8" +current = "4.5.9" # Example of a semver regexp. # Make sure this matches current_version before diff --git a/setup.cfg b/setup.cfg index 27dee96..eff5a19 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = customtkinter -version = 4.5.8 +version = 4.5.9 description = Create modern looking GUIs with Python long_description = CustomTkinter UI-Library\n\n[](https://github.com/TomSchimansky/CustomTkinter/blob/master/documentation_images/Windows_dark.png)\n\nMore Information: https://github.com/TomSchimansky/CustomTkinter long_description_content_type = text/markdown From 36702326fa83638f6bfff65935bb259b96fa9137 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Mon, 18 Jul 2022 13:02:39 +0200 Subject: [PATCH 15/18] fixed checkbox size bug when rescaling --- customtkinter/widgets/ctk_checkbox.py | 1 + test/manual_integration_tests/complex_example_new.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/customtkinter/widgets/ctk_checkbox.py b/customtkinter/widgets/ctk_checkbox.py index 981eea3..787f1e6 100644 --- a/customtkinter/widgets/ctk_checkbox.py +++ b/customtkinter/widgets/ctk_checkbox.py @@ -118,6 +118,7 @@ class CTkCheckBox(CTkBaseClass): self.grid_columnconfigure(1, weight=0, minsize=self.apply_widget_scaling(6)) self.text_label.configure(font=self.apply_font_scaling(self.text_font)) + self.canvas.delete("checkmark") self.bg_canvas.configure(width=self.apply_widget_scaling(self._desired_width), height=self.apply_widget_scaling(self._desired_height)) self.canvas.configure(width=self.apply_widget_scaling(self._desired_width), height=self.apply_widget_scaling(self._desired_height)) self.draw() diff --git a/test/manual_integration_tests/complex_example_new.py b/test/manual_integration_tests/complex_example_new.py index 20064b3..5899aa4 100644 --- a/test/manual_integration_tests/complex_example_new.py +++ b/test/manual_integration_tests/complex_example_new.py @@ -39,7 +39,7 @@ class App(customtkinter.CTk): self.appearance_mode_optionemenu.grid(row=6, column=0, padx=20, pady=(10, 10)) self.scaling_label = customtkinter.CTkLabel(self.sidebar_frame, text="Widget Scaling:", anchor="w") self.scaling_label.grid(row=7, column=0, padx=20, pady=(10, 0)) - self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["90%", "100%", "110%"], + self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["80%", "90%", "100%", "110%", "120%"], command=self.change_scaling) self.scaling_optionemenu.grid(row=8, column=0, padx=20, pady=(10, 20)) @@ -120,7 +120,7 @@ class App(customtkinter.CTk): self.optionmenu_1.set("CTkOptionmenu") self.combobox_1.set("CTkComboBox") self.textbox.insert("1.0", - "CTkTextbox\n\nLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.", ) + "CTkTextbox\n\nLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.", ) #self.textbox.tag_add("headline", "1.0", "1.end") #self.textbox.tag_config("headline", foreground="red") From e295674e00832a44e97349b15557b31421b3d4b2 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sat, 23 Jul 2022 19:09:53 +0200 Subject: [PATCH 16/18] fixed bug in CTkLabel with multiline strings --- customtkinter/widgets/ctk_label.py | 7 +++++-- test/manual_integration_tests/complex_example_new.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/customtkinter/widgets/ctk_label.py b/customtkinter/widgets/ctk_label.py index 033841d..c60699b 100644 --- a/customtkinter/widgets/ctk_label.py +++ b/customtkinter/widgets/ctk_label.py @@ -119,7 +119,8 @@ class CTkLabel(CTkBaseClass): sticky=text_label_grid_sticky) if "text" in kwargs: - self.set_text(kwargs["text"]) + self.text = kwargs["text"] + self.text_label.configure(text=self.text) del kwargs["text"] if "fg_color" in kwargs: @@ -148,5 +149,7 @@ class CTkLabel(CTkBaseClass): self.text_label.configure(**kwargs) # pass remaining kwargs to label def set_text(self, text): + """ Will be removed in the next major release """ + self.text = text - self.text_label.configure(text=self.text, width=len(self.text)) + self.text_label.configure(text=self.text) diff --git a/test/manual_integration_tests/complex_example_new.py b/test/manual_integration_tests/complex_example_new.py index 5899aa4..53d1854 100644 --- a/test/manual_integration_tests/complex_example_new.py +++ b/test/manual_integration_tests/complex_example_new.py @@ -37,7 +37,7 @@ class App(customtkinter.CTk): self.appearance_mode_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["Light", "Dark", "System"], command=self.change_appearance_mode) self.appearance_mode_optionemenu.grid(row=6, column=0, padx=20, pady=(10, 10)) - self.scaling_label = customtkinter.CTkLabel(self.sidebar_frame, text="Widget Scaling:", anchor="w") + self.scaling_label = customtkinter.CTkLabel(self.sidebar_frame, text="UI Scaling:", anchor="w") self.scaling_label.grid(row=7, column=0, padx=20, pady=(10, 0)) self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["80%", "90%", "100%", "110%", "120%"], command=self.change_scaling) From 156a1863f504cbfc0f52be3a5157dbc8ad000e44 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sat, 23 Jul 2022 20:03:59 +0200 Subject: [PATCH 17/18] Bump to 4.5.10 --- customtkinter/__init__.py | 2 +- pyproject.toml | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/customtkinter/__init__.py b/customtkinter/__init__.py index c9d233c..2fe35a0 100644 --- a/customtkinter/__init__.py +++ b/customtkinter/__init__.py @@ -1,4 +1,4 @@ -__version__ = "4.5.9" +__version__ = "4.5.10" import os import sys diff --git a/pyproject.toml b/pyproject.toml index 86042bd..6fbe798 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" github_url = "https://github.com/TomSchimansky/CustomTkinter" [tool.tbump.version] -current = "4.5.9" +current = "4.5.10" # Example of a semver regexp. # Make sure this matches current_version before diff --git a/setup.cfg b/setup.cfg index eff5a19..7531784 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = customtkinter -version = 4.5.9 +version = 4.5.10 description = Create modern looking GUIs with Python long_description = CustomTkinter UI-Library\n\n[](https://github.com/TomSchimansky/CustomTkinter/blob/master/documentation_images/Windows_dark.png)\n\nMore Information: https://github.com/TomSchimansky/CustomTkinter long_description_content_type = text/markdown From ec8cecb5757850d2e1d03062bdca68fd95338677 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Mon, 25 Jul 2022 11:25:48 +0200 Subject: [PATCH 18/18] fixed window closing returning None of CTkInputDialog --- customtkinter/windows/ctk_input_dialog.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/customtkinter/windows/ctk_input_dialog.py b/customtkinter/windows/ctk_input_dialog.py index 0e3d198..d0c204f 100644 --- a/customtkinter/windows/ctk_input_dialog.py +++ b/customtkinter/windows/ctk_input_dialog.py @@ -42,6 +42,8 @@ class CTkInputDialog: self.top.focus_force() self.top.grab_set() + self.top.protocol("WM_DELETE_WINDOW", self.on_closing) + self.top.after(10, self.create_widgets) # create widgets with slight delay, to avoid white flickering of background def create_widgets(self): @@ -95,6 +97,9 @@ class CTkInputDialog: self.user_input = self.entry.get() self.running = False + def on_closing(self): + self.running = False + def cancel_event(self): self.running = False