CustomTkinter
CustomTkinter copied to clipboard
CTkTextbox cget() problem
There are multiple arguments which cannot be fetched with .cget() for a CTkTextbox.
For example: spacing1, spacing2, spacing3, state, etc. (I have not checked all)
File "example.py", line 147, in __init__
print(self.textbox.cget("spacing1"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...\customtkinter\windows\widgets\ctk_textbox.py", line 327, in cget
return super().cget(attribute_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Using self.textbox.cget() does not work for all attributes, some of them need self.textbox._textbox.cget() instead.
The cget() of CTkTextbox class in ctk_textbox.py would require an update I assume.
def cget(self, attribute_name: str) -> any:
if attribute_name == "corner_radius":
return self._corner_radius
elif attribute_name == "border_width":
return self._border_width
elif attribute_name == "border_spacing":
return self._border_spacing
elif attribute_name == "fg_color":
return self._fg_color
elif attribute_name == "border_color":
return self._border_color
elif attribute_name == "text_color":
return self._text_color
elif attribute_name == "font":
return self._font
elif attribute_name == "spacing1":
return self._textbox.cget(attribute_name)
elif attribute_name == "spacing2":
return self._textbox.cget(attribute_name)
elif attribute_name == "spacing3":
return self._textbox.cget(attribute_name)
elif attribute_name == "state":
return self._textbox.cget(attribute_name)
# elif ... whichever attribute needs self._textbox
else:
return super().cget(attribute_name)
@rtommy
Try this:
self.textbox._textbox.cget("spacing1")
@rtommy Try this:
self.textbox._textbox.cget("spacing1")
Yes, I know that works. That’s why I could propose an idea what to change in cget().
It would be more practical if we didn’t need to consider adding _textbox …