diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a150d0..29faa63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ToDo: - complete other theme files + - create grayscale theme file - change font attribute in wiki - add new button attributes to wiki + - cursor configuring - overwrite winfo methods @@ -18,6 +20,7 @@ ToDo: - Added CTkTabview - Added .cget() method to all widgets and windows - Added .bind() and .focus() methods to almost all widgets + - Added 'anchor' option to CTkButton to position image and text inside the button - Added 'anchor' option to CTkOptionMenu and 'justify' option to CTkComboBox - Added CTkFont class - Added CTkImage class to replace PIL.ImageTk.PhotoImage, supports scaling and two images for appearance mode, supports configuring diff --git a/customtkinter/__init__.py b/customtkinter/__init__.py index 4ac2e04..15e95db 100644 --- a/customtkinter/__init__.py +++ b/customtkinter/__init__.py @@ -2,6 +2,11 @@ __version__ = "4.6.3" import os import sys +import tkinter.filedialog as filedialog +from tkinter import Variable, StringVar, IntVar, DoubleVar, BooleanVar +from tkinter.constants import * + +_ = filedialog, Variable, StringVar, IntVar, DoubleVar, BooleanVar, CENTER # prevent IDE from removing unused imports # import manager classes from .windows.widgets.appearance_mode.appearance_mode_tracker import AppearanceModeTracker diff --git a/customtkinter/windows/widgets/ctk_entry.py b/customtkinter/windows/widgets/ctk_entry.py index ded3daa..736b6c1 100644 --- a/customtkinter/windows/widgets/ctk_entry.py +++ b/customtkinter/windows/widgets/ctk_entry.py @@ -163,28 +163,28 @@ class CTkEntry(CTkBaseClass): fill=self._apply_appearance_mode(self._bg_color), outline=self._apply_appearance_mode(self._bg_color)) self._entry.configure(bg=self._apply_appearance_mode(self._bg_color), - fg=self._apply_appearance_mode(self._text_color), disabledbackground=self._apply_appearance_mode(self._bg_color), - disabledforeground=self._apply_appearance_mode(self._text_color), - highlightcolor=self._apply_appearance_mode(self._bg_color), - insertbackground=self._apply_appearance_mode(self._text_color)) + highlightcolor=self._apply_appearance_mode(self._bg_color)) else: self._canvas.itemconfig("inner_parts", fill=self._apply_appearance_mode(self._fg_color), outline=self._apply_appearance_mode(self._fg_color)) self._entry.configure(bg=self._apply_appearance_mode(self._fg_color), - fg=self._apply_appearance_mode(self._text_color), disabledbackground=self._apply_appearance_mode(self._fg_color), - disabledforeground=self._apply_appearance_mode(self._text_color), - highlightcolor=self._apply_appearance_mode(self._fg_color), - insertbackground=self._apply_appearance_mode(self._text_color)) + highlightcolor=self._apply_appearance_mode(self._fg_color)) self._canvas.itemconfig("border_parts", fill=self._apply_appearance_mode(self._border_color), outline=self._apply_appearance_mode(self._border_color)) if self._placeholder_text_active: - self._entry.config(fg=self._apply_appearance_mode(self._placeholder_text_color)) + self._entry.config(fg=self._apply_appearance_mode(self._placeholder_text_color), + disabledforeground=self._apply_appearance_mode(self._placeholder_text_color), + insertbackground=self._apply_appearance_mode(self._placeholder_text_color)) + else: + self._entry.config(fg=self._apply_appearance_mode(self._text_color), + disabledforeground=self._apply_appearance_mode(self._text_color), + insertbackground=self._apply_appearance_mode(self._text_color)) def configure(self, require_redraw=False, **kwargs): if "state" in kwargs: @@ -289,7 +289,9 @@ class CTkEntry(CTkBaseClass): self._placeholder_text_active = True self._pre_placeholder_arguments = {"show": self._entry.cget("show")} - self._entry.config(fg=self._apply_appearance_mode(self._placeholder_text_color), show="") + self._entry.config(fg=self._apply_appearance_mode(self._placeholder_text_color), + disabledforeground=self._apply_appearance_mode(self._placeholder_text_color), + show="") self._entry.delete(0, tkinter.END) self._entry.insert(0, self._placeholder_text) @@ -297,7 +299,8 @@ class CTkEntry(CTkBaseClass): if self._placeholder_text_active: self._placeholder_text_active = False - self._entry.config(fg=self._apply_appearance_mode(self._text_color)) + self._entry.config(fg=self._apply_appearance_mode(self._text_color), + disabledforeground=self._apply_appearance_mode(self._text_color),) self._entry.delete(0, tkinter.END) for argument, value in self._pre_placeholder_arguments.items(): self._entry[argument] = value diff --git a/test/manual_integration_tests/test_all_widgets_with_colors.py b/test/manual_integration_tests/test_all_widgets_with_colors.py index acf75a7..f1b06ed 100644 --- a/test/manual_integration_tests/test_all_widgets_with_colors.py +++ b/test/manual_integration_tests/test_all_widgets_with_colors.py @@ -110,11 +110,11 @@ class TestApp(customtkinter.CTk): self.frame_3.place(relx=0.5, y=y + 80, anchor=tkinter.CENTER) self.frame_3.configure(fg_color=("#EBECF3", "#4B577E")) - self.button_3 = customtkinter.CTkButton(master=self.ctk_frame_customized, command=lambda: x, border_width=3, + self.button_3 = customtkinter.CTkButton(master=self.ctk_frame_customized, command=lambda: None, border_width=3, corner_radius=20, font=("times", 16)) self.button_3.place(relx=0.5, y=y + 160, anchor=tkinter.CENTER) self.button_3.configure(border_color=("#4F90F8", "#6FADF9"), hover_color=("#3A65E8", "#4376EE")) - self.button_3.configure(fg_color=None) + self.button_3.configure(fg_color="transparent") self.entry_3 = customtkinter.CTkEntry(master=self.ctk_frame_customized, font=("times", 16)) self.entry_3.place(relx=0.5, y=y + 240, anchor=tkinter.CENTER) @@ -152,7 +152,7 @@ class TestApp(customtkinter.CTk): self.button_4 = customtkinter.CTkButton(master=self.tk_frame_customized, command=lambda: x, border_width=3) self.button_4.place(relx=0.5, y=y + 160, anchor=tkinter.CENTER) self.button_4.configure(border_color=("#4F90F8", "#6FADF9"), hover_color=("#3A65E8", "#4376EE")) - self.button_4.configure(fg_color=None) + self.button_4.configure(fg_color="transparent") self.entry_4 = customtkinter.CTkEntry(master=self.tk_frame_customized) self.entry_4.place(relx=0.5, y=y + 240, anchor=tkinter.CENTER) diff --git a/test/manual_integration_tests/test_string_dialog.py b/test/manual_integration_tests/test_string_dialog.py index 76b2526..ba947e6 100644 --- a/test/manual_integration_tests/test_string_dialog.py +++ b/test/manual_integration_tests/test_string_dialog.py @@ -15,14 +15,21 @@ def change_mode(): customtkinter.set_appearance_mode("dark") -def button_click_event(): - dialog = customtkinter.CTkInputDialog(master=None, text="Type in a number:", title="Test") +def button_1_click_event(): + dialog = customtkinter.CTkInputDialog(text="Type in a number:", title="Test") print("Number:", dialog.get_input()) -button = customtkinter.CTkButton(app, text="Open Dialog", command=button_click_event) -button.place(relx=0.5, rely=0.5, anchor=customtkinter.CENTER) +def button_2_click_event(): + dialog = customtkinter.CTkInputDialog(text="long text "*100, title="Test") + print("Number:", dialog.get_input()) + + +button_1 = customtkinter.CTkButton(app, text="Open Dialog", command=button_1_click_event) +button_1.pack(pady=20) +button_2 = customtkinter.CTkButton(app, text="Open Dialog", command=button_2_click_event) +button_2.pack(pady=20) c1 = customtkinter.CTkCheckBox(app, text="dark mode", command=change_mode) -c1.place(relx=0.5, rely=0.8, anchor=customtkinter.CENTER) +c1.pack(pady=20) app.mainloop() diff --git a/test/manual_integration_tests/test_vertical_widgets.py b/test/manual_integration_tests/test_vertical_widgets.py index 3b2feab..92bd06d 100644 --- a/test/manual_integration_tests/test_vertical_widgets.py +++ b/test/manual_integration_tests/test_vertical_widgets.py @@ -7,17 +7,17 @@ app.title("test_vertical_widgets") app.grid_columnconfigure(0, weight=1) app.grid_rowconfigure((0, 1, 2, 3), weight=1) -progressbar_1 = customtkinter.CTkProgressBar(app, orient="horizontal") +progressbar_1 = customtkinter.CTkProgressBar(app, orientation="horizontal") progressbar_1.grid(row=0, column=0, pady=20, padx=20) -progressbar_2 = customtkinter.CTkProgressBar(app, orient="vertical") +progressbar_2 = customtkinter.CTkProgressBar(app, orientation="vertical") progressbar_2.grid(row=1, column=0, pady=20, padx=20) -slider_1 = customtkinter.CTkSlider(app, orient="horizontal", command=progressbar_1.set, +slider_1 = customtkinter.CTkSlider(app, orientation="horizontal", command=progressbar_1.set, button_corner_radius=3, button_length=20) slider_1.grid(row=2, column=0, pady=20, padx=20) -slider_2 = customtkinter.CTkSlider(app, orient="vertical", command=progressbar_2.set, +slider_2 = customtkinter.CTkSlider(app, orientation="vertical", command=progressbar_2.set, button_corner_radius=3, button_length=20) slider_2.grid(row=3, column=0, pady=20, padx=20)