From a8b9b4290cd1747192fa2605b9757fa1581623a4 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Tue, 8 Feb 2022 20:59:50 +0100 Subject: [PATCH] fixed bug in CTkEntry, aligned text in CTkCheckBox --- Readme.md | 15 ++++++++------- customtkinter/customtkinter_button.py | 2 +- customtkinter/customtkinter_checkbox.py | 5 ++++- customtkinter/customtkinter_color_manager.py | 8 +++++--- customtkinter/customtkinter_entry.py | 2 +- examples/complex_example.py | 10 +++------- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Readme.md b/Readme.md index ee58317..76e4ed0 100644 --- a/Readme.md +++ b/Readme.md @@ -212,7 +212,7 @@ argument | value master | root, tkinter.Frame or CTkFrame width | slider width in px height | slider height in px -fg_color | forground color, tuple: (light_color, dark_color) or single color +fg_color | foreground color, tuple: (light_color, dark_color) or single color bg_color | background color, tuple: (light_color, dark_color) or single color @@ -293,7 +293,7 @@ text | string width | label width in px height | label height in px corner_radius | corner radius in px -fg_color | forground color, tuple: (light_color, dark_color) or single color +fg_color | foreground color, tuple: (light_color, dark_color) or single color bg_color | background color, tuple: (light_color, dark_color) or single color, None for transparent bg text_color | label text color, tuple: (light_color, dark_color) or single color text_font | label text font, tuple: (font_name, size) @@ -313,6 +313,7 @@ CTkLabel.configure(fg_color=new_fg_color, Example Code: ```python entry = customtkinter.CTkEntry(master=root_tk, + placeholder_text="CTkEntry", width=120, height=25, corner_radius=10) @@ -330,7 +331,7 @@ variable | tkinter.StringVar object width | entry width in px height | entry height in px corner_radius | corner radius in px -fg_color | forground color, tuple: (light_color, dark_color) or single color +fg_color | foreground color, tuple: (light_color, dark_color) or single color bg_color | background color, tuple: (light_color, dark_color) or single color text_color | entry text color, tuple: (light_color, dark_color) or single color placeholder_text_color | tuple: (light_color, dark_color) or single color @@ -341,7 +342,7 @@ text_font | entry text font, tuple: (font_name, size) CTkEntry Methods: ```python -CTkEntry.delete(...) # standard tkinter Entry... +CTkEntry.delete(...) # like the standard tkinter Entry... CTkEntry.insert(...) text = CTkEntry.get() ``` @@ -367,7 +368,7 @@ width | box width in px height | box height in px corner_radius | corner radius in px border_width | box border width in px -fg_color | forground (inside) color, tuple: (light_color, dark_color) or single color +fg_color | foreground (inside) color, tuple: (light_color, dark_color) or single color bg_color | background color, tuple: (light_color, dark_color) or single color border_color | border color, tuple: (light_color, dark_color) or single color hover_color | hover color, tuple: (light_color, dark_color) or single color @@ -423,7 +424,7 @@ from_ | lower slider value to | upper slider value number_of_steps | number of steps in which the slider can be positioned border_width | space around the slider rail in px -fg_color | forground color, tuple: (light_color, dark_color) or single color +fg_color | foreground color, tuple: (light_color, dark_color) or single color progress_color | tuple: (light_color, dark_color) or single color, colors the slider line before the round button and is set to fg_color by default bg_color | background color, tuple: (light_color, dark_color) or single color border_color | slider border color, normally transparent (None) @@ -458,7 +459,7 @@ master | root, tkinter.Frame or CTkFrame width | slider width in px height | slider height in px border_width | border width in px -fg_color | forground color, tuple: (light_color, dark_color) or single color +fg_color | foreground color, tuple: (light_color, dark_color) or single color bg_color | background color, tuple: (light_color, dark_color) or single color border_color | slider border color, tuple: (light_color, dark_color) or single color progress_color | progress color, tuple: (light_color, dark_color) or single color diff --git a/customtkinter/customtkinter_button.py b/customtkinter/customtkinter_button.py index d34e1ea..a384ec8 100644 --- a/customtkinter/customtkinter_button.py +++ b/customtkinter/customtkinter_button.py @@ -111,7 +111,7 @@ class CTkButton(tkinter.Frame): highlightthicknes=0, width=self.width, height=self.height) - self.canvas.grid(row=1, column=0, rowspan=2, columnspan=2) + self.canvas.grid(row=0, column=0, rowspan=2, columnspan=2, sticky="nsew") # event bindings if self.hover is True: diff --git a/customtkinter/customtkinter_checkbox.py b/customtkinter/customtkinter_checkbox.py index 26ed176..029b48f 100644 --- a/customtkinter/customtkinter_checkbox.py +++ b/customtkinter/customtkinter_checkbox.py @@ -258,8 +258,11 @@ class CTkCheckBox(tkinter.Frame): self.text_label = tkinter.Label(master=self, text=self.text, + justify=tkinter.LEFT, + width=len(self.text_color), font=self.text_font) - self.text_label.pack(side='right', padx="4") + self.text_label.pack(side='right', padx=6) + self.text_label["anchor"] = "w" if type(self.text_color) == tuple and len(self.text_color) == 2: self.text_label.configure(fg=self.text_color[self.appearance_mode]) diff --git a/customtkinter/customtkinter_color_manager.py b/customtkinter/customtkinter_color_manager.py index 5d66e13..b5096a9 100644 --- a/customtkinter/customtkinter_color_manager.py +++ b/customtkinter/customtkinter_color_manager.py @@ -39,10 +39,11 @@ class CTkColorManager: elif theme_name.lower() == "green": cls.WINDOW_BG = ("#ECECEC", "#323232") # macOS standard light and dark window bg colors - cls.MAIN = ("#29B57E", "#29B57E") - cls.MAIN_HOVER = ("#6ACBA5", "#6ACBA5") + cls.MAIN = ("#13C995", "#1ABE87") + cls.MAIN_HOVER = ("#6ACBA5", "#81E4B2") cls.ENTRY = ("gray60", "#222223") - cls.TEXT = ("black", "white") + cls.TEXT = ("gray25", "gray92") + cls.PLACEHOLDER_TEXT = ("gray32", "gray55") cls.LABEL_BG = ("white", "#626061") cls.SLIDER_BG = ("#636363", "#0D1321") cls.SLIDER_PROGRESS = ("white", "#727578") @@ -58,6 +59,7 @@ class CTkColorManager: cls.MAIN_HOVER = ("#A4BDE6", "#748BB3") cls.ENTRY = ("#FCFCFC", "#111116") cls.TEXT = ("black", "white") + cls.PLACEHOLDER_TEXT = ("gray52", "gray62") cls.LABEL_BG = ("white", "#444444") cls.SLIDER_BG = ("#444444", "#444444") cls.SLIDER_PROGRESS = ("white", "#AAAAAA") diff --git a/customtkinter/customtkinter_entry.py b/customtkinter/customtkinter_entry.py index 903e214..a5bc327 100644 --- a/customtkinter/customtkinter_entry.py +++ b/customtkinter/customtkinter_entry.py @@ -85,7 +85,7 @@ class CTkEntry(tkinter.Frame): highlightthicknes=0, width=self.width, height=self.height) - self.canvas.grid(column=0, row=0) + self.canvas.grid(column=0, row=0, sticky="we") self.entry = tkinter.Entry(master=self, bd=0, diff --git a/examples/complex_example.py b/examples/complex_example.py index d3c2d31..582a332 100644 --- a/examples/complex_example.py +++ b/examples/complex_example.py @@ -4,7 +4,7 @@ import customtkinter import sys customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light" -customtkinter.set_default_color_theme("green") # Themes: "blue" (standard), "green", "dark-blue" +customtkinter.set_default_color_theme("dark-blue") # Themes: "blue" (standard), "green", "dark-blue" class App(customtkinter.CTk): @@ -94,10 +94,6 @@ class App(customtkinter.CTk): height=12) self.progressbar.place(relx=0.5, rely=0.85, anchor=tkinter.S) - # from tkintermapview import TkinterMapView - # self.map_widget = TkinterMapView(self.frame_info, width=380, height=200, corner_radius=10) - # self.map_widget.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER) - # ============ frame_right <- ============ self.slider_1 = customtkinter.CTkSlider(master=self.frame_right, @@ -138,9 +134,9 @@ class App(customtkinter.CTk): self.entry = customtkinter.CTkEntry(master=self.frame_right, width=120, height=25, - corner_radius=8) + corner_radius=8, + placeholder_text="CTkEntry") self.entry.place(relx=0.33, rely=0.92, anchor=tkinter.CENTER) - self.entry.insert(0, "CTkEntry") self.button_5 = customtkinter.CTkButton(master=self.frame_right, height=25,