Calab
(Steve Norton)
1
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()
MRAB
(Matthew Barnett)
2
The 3rd argument of .insert
is the name, not the text.
I always let it make its own name:
item_iid = tree_view.insert("", tk.END, text="Item")
subitem_iid = tree_view.insert(item_iid, tk.END, text="SubItem")
1 Like
tjreedy
(Terry Jan Reedy)
3
By reading the treeview doc, I fixed the insert lines.
item = tree_view.insert("", 'end', text="Item")
tree_view.insert(item, tk.END, text="SubItem")
Look particularly at the Item Options
and insert
entries.
1 Like
Calab
(Steve Norton)
4
That’s what happens when I read too quickly.
Thank you very much for the help!