'Python tkinter treeview insert from a list
Do you know if there is another way than using a 'for' loop to feed the tkinter treeview widget from a list, because the loading time is relatively long with this instruction?
Thanks for your answers!
my_list = []
for i in range(1, 1_000_001):
my_list.append(i)
root = tk.Tk()
root.geometry('800x600')
my_treeview = ttk.Treeview(root)
my_treeview['columns'] = 'Données'
for column in my_treeview['columns']:
my_treeview.heading(column, text=column)
for item in my_list:
my_treeview.insert('', 'end', values=item)
my_treeview.pack()
root.mainloop()
Loading time: about 5 seconds
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
