0

I'm trying to use the ttk treeview widget. I'm able to create and populate it, and it seems to work properly. However it is rendering with a large empty "column" on the left side and I can't figure out what is causing it. I've verified that column(0) is the first column I defined so don't know where this is coming from. Code to create the treeview:

cols = ("EIR", "Env", "Name", "Function", "IP", "Model")
col_widths = (75, 50, 120, 150, 100, 150)
self.tv = tv = ttk.Treeview(self, columns=cols)
for col, col_w in zip(cols, col_widths):
 tv.column(column=col, width=col_w, anchor=tk.W)
 tv.heading(column=col, text=col, anchor=tk.W)

Rendered treeview: Treeview with empty column on left

asked Oct 3, 2024 at 18:04

2 Answers 2

1

Try adding

self.tv = tv = ttk.Treeview(self, columns=cols)
self.tv["show"] = "headings" # <- Added line
answered Oct 3, 2024 at 18:17
Sign up to request clarification or add additional context in comments.

Comments

1

Issue solved by adding show='headings' to initial load:

self.tv = tv = ttk.Treeview(self, columns=cols, show='headings')
answered Oct 3, 2024 at 18:23

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.