Tkinter Treeview not showing any text

I’m using python 3.12.2 and Tcl/Tk 8.6.13.

When I create a Treeview, the tree is there, but there is no text shown.

I’m not sure if this is an issue with my code, with tkinter, or an issue with a font on my Windows 11 system.

Any idea why I don’t see any text?

See this example:

import tkinter as tk
from tkinter import ttk

window = tk.Tk()
tree_view = ttk.Treeview()
tree_view.insert("", tk.END, "Item")
tree_view.insert("Item", tk.END, "SubItem")

tree_view.pack()

window.mainloop()

image

Found the answer…

#1. It helps to put parameters in the correct place, or name them (“text” in this case)

#2. I had to have a reference to the item I was adding so I could use it to add the sub item.

item = tree_view.insert("", tk.END, text="Item")
subitem = tree_view.insert(item, tk.END, text="SubItem")