From 8b85225133501940a8e17a86711b373adba4d18a Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Tue, 4 Oct 2022 03:16:59 +0200 Subject: [PATCH] fixed typo in all unbind methods --- CHANGELOG.md | 2 -- customtkinter/widgets/ctk_button.py | 2 +- customtkinter/widgets/ctk_checkbox.py | 2 +- customtkinter/widgets/ctk_combobox.py | 2 +- customtkinter/widgets/ctk_entry.py | 4 +-- customtkinter/widgets/ctk_frame.py | 2 +- customtkinter/widgets/ctk_label.py | 2 +- customtkinter/widgets/ctk_optionmenu.py | 2 +- customtkinter/widgets/ctk_progressbar.py | 2 +- customtkinter/widgets/ctk_radiobutton.py | 2 +- customtkinter/widgets/ctk_scrollbar.py | 2 +- customtkinter/widgets/ctk_slider.py | 2 +- customtkinter/widgets/ctk_switch.py | 2 +- customtkinter/widgets/ctk_textbox.py | 32 +++++++++++++------ .../complex_example_new.py | 1 + 15 files changed, 37 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78b0d86..e85c215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ToDo: - - limit configuring attributes of overridden tk widgets (to be finished) - remove bg and background support for CTk and CTkToplevel (to be done) - - optimize font attribute managing - enforce font size in pixel - enforce font to be tuple diff --git a/customtkinter/widgets/ctk_button.py b/customtkinter/widgets/ctk_button.py index 1cd70ab..a8dc969 100644 --- a/customtkinter/widgets/ctk_button.py +++ b/customtkinter/widgets/ctk_button.py @@ -415,4 +415,4 @@ class CTkButton(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Canvas """ - return self._canvas.bind(sequence, funcid) + return self._canvas.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_checkbox.py b/customtkinter/widgets/ctk_checkbox.py index ac85ccb..8c1aaf8 100644 --- a/customtkinter/widgets/ctk_checkbox.py +++ b/customtkinter/widgets/ctk_checkbox.py @@ -370,4 +370,4 @@ class CTkCheckBox(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Canvas """ - return self._canvas.bind(sequence, funcid) + return self._canvas.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_combobox.py b/customtkinter/widgets/ctk_combobox.py index 2721e0c..aa7286d 100644 --- a/customtkinter/widgets/ctk_combobox.py +++ b/customtkinter/widgets/ctk_combobox.py @@ -356,4 +356,4 @@ class CTkComboBox(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Entry """ - return self._entry.bind(sequence, funcid) + return self._entry.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_entry.py b/customtkinter/widgets/ctk_entry.py index f452dc8..d404a43 100644 --- a/customtkinter/widgets/ctk_entry.py +++ b/customtkinter/widgets/ctk_entry.py @@ -70,7 +70,7 @@ class CTkEntry(CTkBaseClass): self._state = state self._textvariable_callback_name: str = "" - if not (self._textvariable is None or self._textvariable is ""): + if not (self._textvariable is None or self._textvariable == ""): self._textvariable_callback_name = self._textvariable.trace_add("write", self._textvariable_callback) self._canvas = CTkCanvas(master=self, @@ -265,7 +265,7 @@ class CTkEntry(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Entry """ - return self._entry.bind(sequence, funcid) + return self._entry.unbind(sequence, funcid) def _activate_placeholder(self): if self._entry.get() == "" and self._placeholder_text is not None and (self._textvariable is None or self._textvariable == ""): diff --git a/customtkinter/widgets/ctk_frame.py b/customtkinter/widgets/ctk_frame.py index 14b55df..adda306 100644 --- a/customtkinter/widgets/ctk_frame.py +++ b/customtkinter/widgets/ctk_frame.py @@ -164,4 +164,4 @@ class CTkFrame(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Canvas """ - return self._canvas.bind(sequence, funcid) + return self._canvas.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_label.py b/customtkinter/widgets/ctk_label.py index e5537eb..ff4f2d9 100644 --- a/customtkinter/widgets/ctk_label.py +++ b/customtkinter/widgets/ctk_label.py @@ -188,4 +188,4 @@ class CTkLabel(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Label """ - return self._text_label.bind(sequence, funcid) + return self._text_label.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_optionmenu.py b/customtkinter/widgets/ctk_optionmenu.py index 3e9d81c..c803219 100644 --- a/customtkinter/widgets/ctk_optionmenu.py +++ b/customtkinter/widgets/ctk_optionmenu.py @@ -364,4 +364,4 @@ class CTkOptionMenu(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Label """ - return self._text_label.bind(sequence, funcid) + return self._text_label.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_progressbar.py b/customtkinter/widgets/ctk_progressbar.py index 0e31f33..8c32c8c 100644 --- a/customtkinter/widgets/ctk_progressbar.py +++ b/customtkinter/widgets/ctk_progressbar.py @@ -289,4 +289,4 @@ class CTkProgressBar(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Canvas """ - return self._canvas.bind(sequence, funcid) + return self._canvas.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_radiobutton.py b/customtkinter/widgets/ctk_radiobutton.py index 89fdddc..b80c428 100644 --- a/customtkinter/widgets/ctk_radiobutton.py +++ b/customtkinter/widgets/ctk_radiobutton.py @@ -332,4 +332,4 @@ class CTkRadioButton(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Canvas """ - return self._canvas.bind(sequence, funcid) + return self._canvas.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_scrollbar.py b/customtkinter/widgets/ctk_scrollbar.py index 4c550ea..6924a7b 100644 --- a/customtkinter/widgets/ctk_scrollbar.py +++ b/customtkinter/widgets/ctk_scrollbar.py @@ -256,4 +256,4 @@ class CTkScrollbar(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Canvas """ - return self._canvas.bind(sequence, funcid) + return self._canvas.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_slider.py b/customtkinter/widgets/ctk_slider.py index 7b8af7c..06600c5 100644 --- a/customtkinter/widgets/ctk_slider.py +++ b/customtkinter/widgets/ctk_slider.py @@ -372,4 +372,4 @@ class CTkSlider(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Canvas """ - return self._canvas.bind(sequence, funcid) + return self._canvas.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_switch.py b/customtkinter/widgets/ctk_switch.py index 90bf2c1..05f6ab1 100644 --- a/customtkinter/widgets/ctk_switch.py +++ b/customtkinter/widgets/ctk_switch.py @@ -381,4 +381,4 @@ class CTkSwitch(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Canvas """ - return self._canvas.bind(sequence, funcid) + return self._canvas.unbind(sequence, funcid) diff --git a/customtkinter/widgets/ctk_textbox.py b/customtkinter/widgets/ctk_textbox.py index 523533f..87648ba 100644 --- a/customtkinter/widgets/ctk_textbox.py +++ b/customtkinter/widgets/ctk_textbox.py @@ -11,7 +11,7 @@ from .widget_helper_functions import pop_from_dict_by_set class CTkTextbox(CTkBaseClass): """ - Textbox with rounded corners, and all text features of tkinter Text widget. + Textbox with rounded corners, and all text features of tkinter.Text widget. For detailed information check out the documentation. """ @@ -78,7 +78,9 @@ class CTkTextbox(CTkBaseClass): insertbackground=ThemeManager.single_color(self._text_color, self._appearance_mode), bg=ThemeManager.single_color(self._fg_color, self._appearance_mode), **pop_from_dict_by_set(kwargs, self._valid_tk_text_attributes)) - self._textbox.grid(row=0, column=0, padx=self._corner_radius, pady=self._corner_radius, rowspan=1, columnspan=1, sticky="nsew") + self._textbox.grid(row=0, column=0, rowspan=1, columnspan=1, sticky="nsew", + padx=self._apply_widget_scaling(self._corner_radius), + pady=self._apply_widget_scaling(self._corner_radius)) self._check_kwargs_empty(kwargs, raise_error=True) @@ -89,6 +91,10 @@ class CTkTextbox(CTkBaseClass): super()._set_scaling(*args, **kwargs) self._textbox.configure(font=self._apply_font_scaling(self._font)) + self._textbox.grid(row=0, column=0, rowspan=1, columnspan=1, sticky="nsew", + padx=self._apply_widget_scaling(self._corner_radius), + pady=self._apply_widget_scaling(self._corner_radius)) + self._canvas.configure(width=self._apply_widget_scaling(self._desired_width), height=self._apply_widget_scaling(self._desired_height)) self._draw() @@ -143,8 +149,15 @@ class CTkTextbox(CTkBaseClass): self._border_color = kwargs.pop("border_color") require_redraw = True + if "text_color" in kwargs: + self._text_color = kwargs.pop("text_color") + require_redraw = True + if "corner_radius" in kwargs: self._corner_radius = kwargs.pop("corner_radius") + self._textbox.grid(row=0, column=0, rowspan=1, columnspan=1, sticky="nsew", + padx=self._apply_widget_scaling(self._corner_radius), + pady=self._apply_widget_scaling(self._corner_radius)) require_redraw = True if "border_width" in kwargs: @@ -161,9 +174,6 @@ class CTkTextbox(CTkBaseClass): self._font = kwargs.pop("font") self._textbox.configure(font=self._apply_font_scaling(self._font)) - if "font" in kwargs: - raise ValueError("No attribute named font. Use text_font instead of font for CTk widgets") - self._textbox.configure(**pop_from_dict_by_set(kwargs, self._valid_tk_text_attributes)) super().configure(require_redraw=require_redraw, **kwargs) @@ -192,7 +202,14 @@ class CTkTextbox(CTkBaseClass): def unbind(self, sequence, funcid=None): """ called on the tkinter.Text """ - return self._textbox.bind(sequence, funcid) + return self._textbox.unbind(sequence, funcid) + + def insert(self, index, text, tags=None): + return self._textbox.insert(index, text, tags) + + def get(self, index1, index2=None): + return self._textbox.get(index1, index2) + def yview(self, *args): return self._textbox.yview(*args) @@ -200,9 +217,6 @@ class CTkTextbox(CTkBaseClass): def xview(self, *args): return self._textbox.xview(*args) - def insert(self, *args, **kwargs): - return self._textbox.insert(*args, **kwargs) - def focus(self): return self._textbox.focus() diff --git a/test/manual_integration_tests/complex_example_new.py b/test/manual_integration_tests/complex_example_new.py index 7779477..ec6f7c2 100644 --- a/test/manual_integration_tests/complex_example_new.py +++ b/test/manual_integration_tests/complex_example_new.py @@ -142,6 +142,7 @@ class App(customtkinter.CTk): def sidebar_button_callback(self): print("sidebar_button click") self.entry.delete(0, tkinter.END) + print(self.textbox.get("0.0", "end")) def on_closing(self, event=0): self.destroy()