pythontkintertreeviewttk

Rendering issue with ttk.TreeView


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


Solution

  • Try adding

    self.tv = tv = ttk.Treeview(self, columns=cols)
    self.tv["show"] = "headings"  # <- Added line