fixed typo in all unbind methods

This commit is contained in:
Tom Schimansky 2022-10-04 03:16:59 +02:00
parent 40474d6905
commit 8b85225133
15 changed files with 37 additions and 24 deletions

View File

@ -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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
ToDo: ToDo:
- limit configuring attributes of overridden tk widgets (to be finished)
- remove bg and background support for CTk and CTkToplevel (to be done) - remove bg and background support for CTk and CTkToplevel (to be done)
- optimize font attribute managing
- enforce font size in pixel - enforce font size in pixel
- enforce font to be tuple - enforce font to be tuple

View File

@ -415,4 +415,4 @@ class CTkButton(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Canvas """ """ called on the tkinter.Canvas """
return self._canvas.bind(sequence, funcid) return self._canvas.unbind(sequence, funcid)

View File

@ -370,4 +370,4 @@ class CTkCheckBox(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Canvas """ """ called on the tkinter.Canvas """
return self._canvas.bind(sequence, funcid) return self._canvas.unbind(sequence, funcid)

View File

@ -356,4 +356,4 @@ class CTkComboBox(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Entry """ """ called on the tkinter.Entry """
return self._entry.bind(sequence, funcid) return self._entry.unbind(sequence, funcid)

View File

@ -70,7 +70,7 @@ class CTkEntry(CTkBaseClass):
self._state = state self._state = state
self._textvariable_callback_name: str = "" 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._textvariable_callback_name = self._textvariable.trace_add("write", self._textvariable_callback)
self._canvas = CTkCanvas(master=self, self._canvas = CTkCanvas(master=self,
@ -265,7 +265,7 @@ class CTkEntry(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Entry """ """ called on the tkinter.Entry """
return self._entry.bind(sequence, funcid) return self._entry.unbind(sequence, funcid)
def _activate_placeholder(self): def _activate_placeholder(self):
if self._entry.get() == "" and self._placeholder_text is not None and (self._textvariable is None or self._textvariable == ""): if self._entry.get() == "" and self._placeholder_text is not None and (self._textvariable is None or self._textvariable == ""):

View File

@ -164,4 +164,4 @@ class CTkFrame(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Canvas """ """ called on the tkinter.Canvas """
return self._canvas.bind(sequence, funcid) return self._canvas.unbind(sequence, funcid)

View File

@ -188,4 +188,4 @@ class CTkLabel(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Label """ """ called on the tkinter.Label """
return self._text_label.bind(sequence, funcid) return self._text_label.unbind(sequence, funcid)

View File

@ -364,4 +364,4 @@ class CTkOptionMenu(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Label """ """ called on the tkinter.Label """
return self._text_label.bind(sequence, funcid) return self._text_label.unbind(sequence, funcid)

View File

@ -289,4 +289,4 @@ class CTkProgressBar(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Canvas """ """ called on the tkinter.Canvas """
return self._canvas.bind(sequence, funcid) return self._canvas.unbind(sequence, funcid)

View File

@ -332,4 +332,4 @@ class CTkRadioButton(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Canvas """ """ called on the tkinter.Canvas """
return self._canvas.bind(sequence, funcid) return self._canvas.unbind(sequence, funcid)

View File

@ -256,4 +256,4 @@ class CTkScrollbar(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Canvas """ """ called on the tkinter.Canvas """
return self._canvas.bind(sequence, funcid) return self._canvas.unbind(sequence, funcid)

View File

@ -372,4 +372,4 @@ class CTkSlider(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Canvas """ """ called on the tkinter.Canvas """
return self._canvas.bind(sequence, funcid) return self._canvas.unbind(sequence, funcid)

View File

@ -381,4 +381,4 @@ class CTkSwitch(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Canvas """ """ called on the tkinter.Canvas """
return self._canvas.bind(sequence, funcid) return self._canvas.unbind(sequence, funcid)

View File

@ -11,7 +11,7 @@ from .widget_helper_functions import pop_from_dict_by_set
class CTkTextbox(CTkBaseClass): 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. For detailed information check out the documentation.
""" """
@ -78,7 +78,9 @@ class CTkTextbox(CTkBaseClass):
insertbackground=ThemeManager.single_color(self._text_color, self._appearance_mode), insertbackground=ThemeManager.single_color(self._text_color, self._appearance_mode),
bg=ThemeManager.single_color(self._fg_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)) **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) self._check_kwargs_empty(kwargs, raise_error=True)
@ -89,6 +91,10 @@ class CTkTextbox(CTkBaseClass):
super()._set_scaling(*args, **kwargs) super()._set_scaling(*args, **kwargs)
self._textbox.configure(font=self._apply_font_scaling(self._font)) 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), self._canvas.configure(width=self._apply_widget_scaling(self._desired_width),
height=self._apply_widget_scaling(self._desired_height)) height=self._apply_widget_scaling(self._desired_height))
self._draw() self._draw()
@ -143,8 +149,15 @@ class CTkTextbox(CTkBaseClass):
self._border_color = kwargs.pop("border_color") self._border_color = kwargs.pop("border_color")
require_redraw = True require_redraw = True
if "text_color" in kwargs:
self._text_color = kwargs.pop("text_color")
require_redraw = True
if "corner_radius" in kwargs: if "corner_radius" in kwargs:
self._corner_radius = kwargs.pop("corner_radius") 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 require_redraw = True
if "border_width" in kwargs: if "border_width" in kwargs:
@ -161,9 +174,6 @@ class CTkTextbox(CTkBaseClass):
self._font = kwargs.pop("font") self._font = kwargs.pop("font")
self._textbox.configure(font=self._apply_font_scaling(self._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)) self._textbox.configure(**pop_from_dict_by_set(kwargs, self._valid_tk_text_attributes))
super().configure(require_redraw=require_redraw, **kwargs) super().configure(require_redraw=require_redraw, **kwargs)
@ -192,7 +202,14 @@ class CTkTextbox(CTkBaseClass):
def unbind(self, sequence, funcid=None): def unbind(self, sequence, funcid=None):
""" called on the tkinter.Text """ """ 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): def yview(self, *args):
return self._textbox.yview(*args) return self._textbox.yview(*args)
@ -200,9 +217,6 @@ class CTkTextbox(CTkBaseClass):
def xview(self, *args): def xview(self, *args):
return self._textbox.xview(*args) return self._textbox.xview(*args)
def insert(self, *args, **kwargs):
return self._textbox.insert(*args, **kwargs)
def focus(self): def focus(self):
return self._textbox.focus() return self._textbox.focus()

View File

@ -142,6 +142,7 @@ class App(customtkinter.CTk):
def sidebar_button_callback(self): def sidebar_button_callback(self):
print("sidebar_button click") print("sidebar_button click")
self.entry.delete(0, tkinter.END) self.entry.delete(0, tkinter.END)
print(self.textbox.get("0.0", "end"))
def on_closing(self, event=0): def on_closing(self, event=0):
self.destroy() self.destroy()