diff --git a/customtkinter/draw_engine.py b/customtkinter/draw_engine.py index 0c530b0..43671cd 100644 --- a/customtkinter/draw_engine.py +++ b/customtkinter/draw_engine.py @@ -546,31 +546,31 @@ class DrawEngine: # create canvas border corner parts if not already created, but only if they're needed and delete if not needed if not self._canvas.find_withtag("inner_oval_1_a") and "inner_oval_1" not in exclude_parts: - self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_1_a", "inner_corner_part", "inner_parts"), anchor=tkinter.CENTER) - self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_1_b", "inner_corner_part", "inner_parts"), anchor=tkinter.CENTER, angle=180) + self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_1_a", "inner_corner_part", "inner_parts_left", "inner_parts"), anchor=tkinter.CENTER) + self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_1_b", "inner_corner_part", "inner_parts_left", "inner_parts"), anchor=tkinter.CENTER, angle=180) requires_recoloring = True elif self._canvas.find_withtag("inner_oval_1_a") and "inner_oval_1" in exclude_parts: self._canvas.delete("inner_oval_1_a", "inner_oval_1_b") if not self._canvas.find_withtag("inner_oval_2_a") and width - (2 * border_width) > 2 * inner_corner_radius and "inner_oval_2" not in exclude_parts: - self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_2_a", "inner_corner_part", "inner_parts"), anchor=tkinter.CENTER) - self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_2_b", "inner_corner_part", "inner_parts"), anchor=tkinter.CENTER, angle=180) + self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_2_a", "inner_corner_part","inner_parts_right", "inner_parts"), anchor=tkinter.CENTER) + self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_2_b", "inner_corner_part", "inner_parts_right","inner_parts"), anchor=tkinter.CENTER, angle=180) requires_recoloring = True elif self._canvas.find_withtag("inner_oval_2_a") and (not width - (2 * border_width) > 2 * inner_corner_radius or "inner_oval_2" in exclude_parts): self._canvas.delete("inner_oval_2_a", "inner_oval_2_b") if not self._canvas.find_withtag("inner_oval_3_a") and height - (2 * border_width) > 2 * inner_corner_radius \ and width - (2 * border_width) > 2 * inner_corner_radius and "inner_oval_3" not in exclude_parts: - self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_3_a", "inner_corner_part", "inner_parts"), anchor=tkinter.CENTER) - self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_3_b", "inner_corner_part", "inner_parts"), anchor=tkinter.CENTER, angle=180) + self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_3_a", "inner_corner_part", "inner_parts_right","inner_parts"), anchor=tkinter.CENTER) + self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_3_b", "inner_corner_part", "inner_parts_right", "inner_parts"), anchor=tkinter.CENTER, angle=180) requires_recoloring = True elif self._canvas.find_withtag("inner_oval_3_a") and (not (height - (2 * border_width) > 2 * inner_corner_radius and width - (2 * border_width) > 2 * inner_corner_radius) or "inner_oval_3" in exclude_parts): self._canvas.delete("inner_oval_3_a", "inner_oval_3_b") if not self._canvas.find_withtag("inner_oval_4_a") and height - (2 * border_width) > 2 * inner_corner_radius and "inner_oval_4" not in exclude_parts: - self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_4_a", "inner_corner_part", "inner_parts"), anchor=tkinter.CENTER) - self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_4_b", "inner_corner_part", "inner_parts"), anchor=tkinter.CENTER, angle=180) + self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_4_a", "inner_corner_part", "inner_parts_left", "inner_parts"), anchor=tkinter.CENTER) + self._canvas.create_aa_circle(0, 0, 0, tags=("inner_oval_4_b", "inner_corner_part", "inner_parts_left", "inner_parts"), anchor=tkinter.CENTER, angle=180) requires_recoloring = True elif self._canvas.find_withtag("inner_oval_4_a") and (not height - (2 * border_width) > 2 * inner_corner_radius or "inner_oval_4" in exclude_parts): self._canvas.delete("inner_oval_4_a", "inner_oval_4_b") @@ -613,11 +613,11 @@ class DrawEngine: height - inner_corner_radius - border_width)) self._canvas.coords("inner_rectangle_right_1", (left_section_width, border_width, - width - border_width, + width - border_width - inner_corner_radius, height - border_width)) self._canvas.coords("inner_rectangle_right_2", (left_section_width, border_width + inner_corner_radius, - width - border_width - inner_corner_radius, + width - border_width, height - inner_corner_radius - border_width)) if requires_recoloring: # new parts were added -> manage z-order diff --git a/customtkinter/theme_manager.py b/customtkinter/theme_manager.py index f62962a..7c70c8a 100644 --- a/customtkinter/theme_manager.py +++ b/customtkinter/theme_manager.py @@ -62,6 +62,19 @@ class ThemeManager: return cls.rgb2hex(new_rgb) + @classmethod + def get_minimal_darker(cls, color: str) -> str: + if color.startswith("#"): + color_rgb = cls.hex2rgb(color) + if color_rgb[0] > 0: + return cls.rgb2hex((color_rgb[0] - 1, color_rgb[1], color_rgb[2])) + elif color_rgb[1] > 0: + return cls.rgb2hex((color_rgb[0], color_rgb[1] - 1, color_rgb[2])) + elif color_rgb[2] > 0: + return cls.rgb2hex((color_rgb[0], color_rgb[1], color_rgb[2] - 1)) + else: + return cls.rgb2hex((color_rgb[0] + 1, color_rgb[1], color_rgb[2] - 1)) # otherwise slightly lighter + @classmethod def multiply_hex_color(cls, hex_color: str, factor: float = 1.0) -> str: try: diff --git a/customtkinter/widgets/dropdown_menu.py b/customtkinter/widgets/dropdown_menu.py index 19e9209..74849e9 100644 --- a/customtkinter/widgets/dropdown_menu.py +++ b/customtkinter/widgets/dropdown_menu.py @@ -8,7 +8,7 @@ from ..appearance_mode_tracker import AppearanceModeTracker class DropdownMenu(tkinter.Toplevel): def __init__(self, *args, - fg_color="gray50", + fg_color="#555555", button_color="gray50", button_hover_color="gray35", text_color="black", @@ -54,15 +54,15 @@ class DropdownMenu(tkinter.Toplevel): elif sys.platform.startswith("win"): self.overrideredirect(True) # remove title-bar - self.configure(bg=ThemeManager.single_color(self.fg_color, self.appearance_mode)) - self.wm_attributes("-transparentcolor", "#FFFFF1") + self.configure(bg="#010302") + self.wm_attributes("-transparentcolor", "#010302") self.focus() self.frame = customtkinter.CTkFrame(self, border_width=0, width=120, corner_radius=self.corner_radius, fg_color=self.fg_color, overwrite_preferred_drawing_method="circle_shapes") else: self.overrideredirect(True) # remove title-bar - self.configure(bg=ThemeManager.single_color(self.fg_color, self.appearance_mode)) - self.wm_attributes("-transparentcolor", "#FFFFF1") + self.configure(bg="#010302") + self.wm_attributes("-transparentcolor", "#010302") self.frame = customtkinter.CTkFrame(self, border_width=0, width=120, corner_radius=self.corner_radius, fg_color=self.fg_color, overwrite_preferred_drawing_method="circle_shapes")