TomSchimansky / TomSchimansky/CustomTkinter

Textbox + Tab View Leads to Errors

Open
#2,127 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
13.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Adding a textbox to a tab view leads to AttributeError: 'CTkTextbox' object has no attribute '_x_scrollbar'.

Minimal example:

import customtkinter as ctk


def create_tab_view(parent):
    tv = ctk.CTkTabview(parent, height=0)
    tv.grid(sticky="nsew")
    tv.add("A")
    txt1 = ctk.CTkTextbox(tv.tab("A"))
    txt1.grid(sticky="WE", padx=10, pady=0)


class main(ctk.CTk):
    def __init__(self, parent=None):
        super().__init__(parent)
        btn = ctk.CTkButton(self, text="test")
        btn.grid(row=0, column=0, sticky="nsew")
        btn.configure(command=lambda: create_tab_view(self))


if __name__ == "__main__":
    root = main()
    root.mainloop()

Then just click the button.

In the __init__ of the CTKTextbox class, during the creation of the self._y_scrollbar, it calls self._canvas.update_idletasks() which for some reason ends up looking for the _x_scrollbar as well... which wasn't made yet.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the CTkTextbox init method, focusing on creation of _y_scrollbar and the self._canvas.update_idletasks() call. Reproduce the issue with the minimal example by clicking the button, then verify that adding a textbox to a tab view no longer raises the _x_scrollbar AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.