From b04ff1ae6bf05d242e54acedaf941af3f5d781fa Mon Sep 17 00:00:00 2001 From: jericjan <38642145+jericjan@users.noreply.github.com> Date: Mon, 29 Aug 2022 13:07:03 +0800 Subject: [PATCH] name support for CTkEntry, CTkLabel, CTkTextbox --- customtkinter/widgets/ctk_entry.py | 10 ++++++---- customtkinter/widgets/ctk_label.py | 11 ++++++----- customtkinter/widgets/ctk_textbox.py | 12 +++++++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/customtkinter/widgets/ctk_entry.py b/customtkinter/widgets/ctk_entry.py index 1fb5d212..9d9c15a7 100644 --- a/customtkinter/widgets/ctk_entry.py +++ b/customtkinter/widgets/ctk_entry.py @@ -24,10 +24,12 @@ def __init__(self, *args, **kwargs): # transfer basic functionality (bg_color, size, _appearance_mode, scaling) to CTkBaseClass - if "master" in kwargs: - super().__init__(*args, bg_color=bg_color, width=width, height=height, master=kwargs.pop("master")) - else: - super().__init__(*args, bg_color=bg_color, width=width, height=height) + super_kwargs = {} + if "master" in kwargs: + super_kwargs['master'] = kwargs.pop("master") + if "name" in kwargs: + super_kwargs['name'] = kwargs.pop("name") + super().__init__(*args, bg_color=bg_color, width=width, height=height,**super_kwargs) # configure grid system (1x1) self.grid_rowconfigure(0, weight=1) diff --git a/customtkinter/widgets/ctk_label.py b/customtkinter/widgets/ctk_label.py index c60699b5..46c22bf3 100644 --- a/customtkinter/widgets/ctk_label.py +++ b/customtkinter/widgets/ctk_label.py @@ -21,11 +21,12 @@ def __init__(self, *args, **kwargs): # transfer basic functionality (bg_color, size, _appearance_mode, scaling) to CTkBaseClass - if "master" in kwargs: - super().__init__(*args, bg_color=bg_color, width=width, height=height, master=kwargs.pop("master")) - else: - super().__init__(*args, bg_color=bg_color, width=width, height=height) - + super_kwargs = {} + if "master" in kwargs: + super_kwargs['master'] = kwargs.pop("master") + if "name" in kwargs: + super_kwargs['name'] = kwargs.pop("name") + super().__init__(*args, bg_color=bg_color, width=width, height=height,**super_kwargs) # color self.fg_color = ThemeManager.theme["color"]["label"] if fg_color == "default_theme" else fg_color if self.fg_color is None: diff --git a/customtkinter/widgets/ctk_textbox.py b/customtkinter/widgets/ctk_textbox.py index 6dfedb22..dd29f210 100644 --- a/customtkinter/widgets/ctk_textbox.py +++ b/customtkinter/widgets/ctk_textbox.py @@ -20,10 +20,12 @@ def __init__(self, *args, **kwargs): # transfer basic functionality (bg_color, size, _appearance_mode, scaling) to CTkBaseClass - if "master" in kwargs: - super().__init__(*args, bg_color=bg_color, width=width, height=height, master=kwargs.pop("master")) - else: - super().__init__(*args, bg_color=bg_color, width=width, height=height) + super_kwargs = {} + if "master" in kwargs: + super_kwargs['master'] = kwargs.pop("master") + if "name" in kwargs: + super_kwargs['name'] = kwargs.pop("name") + super().__init__(*args, bg_color=bg_color, width=width, height=height,**super_kwargs) # color self.fg_color = ThemeManager.theme["color"]["entry"] if fg_color == "default_theme" else fg_color @@ -166,4 +168,4 @@ def configure(self, require_redraw=False, **kwargs): else: super().configure(require_redraw=require_redraw) - self.textbox.configure(**kwargs) + self.textbox.configure(**kwargs) \ No newline at end of file