Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTkTextbox cget() problem #2615

Open
rtommy opened this issue Oct 27, 2024 · 2 comments
Open

CTkTextbox cget() problem #2615

rtommy opened this issue Oct 27, 2024 · 2 comments

Comments

@rtommy
Copy link

rtommy commented Oct 27, 2024

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)
@Akascape
Copy link

@rtommy
Try this:
self.textbox._textbox.cget("spacing1")

@rtommy
Copy link
Author

rtommy commented Oct 27, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants