tkinter Treeview widget à insérer des données

C'est mon exemple de code. Je veux les éléments tapé dans l'entrée pour être inséré dans le contrôle treeview lorsque sur la touche enter. Im nouveau à python et tkinter, et il n'y a pas beaucoup de tutoriaux sur treeview.

class PurchaseEntry(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
PurchaseEntry.configure(self, bg='white')
label = ttk.Label(self, text='Purchase Entry', font=LARGE_FONT2)
label.grid(row=0, columnspan=3, sticky='w')
purchase_entry = ttk.Label(self, text='Purchase Entry:')
purchase_entry.grid(row=1, column=0)
self.entry_val = tk.StringVar()
self.entry_1 = ttk.Entry(self, width=100, textvariable=self.entry_val)
self.entry_1.grid(row=1, column=2, columnspan=2, sticky='w')
self.entry_1.focus()
self.entry_btn = ttk.Button(self,text='Enter', command=self.insert_value)
self.entry_btn.grid(row=1, column=4, columnspan=2, sticky='w')
self.chat1 = ttk.Treeview(self)
chat1 = ttk.Treeview( self, height=28, columns=('dose', 'date   modified'), selectmode="extended")
chat1.heading('#0', text='item', anchor=tk.CENTER)
chat1.heading('#1', text='dose', anchor=tk.CENTER)
chat1.heading('#2', text='date modified', anchor=tk.CENTER)
chat1.column('#1', stretch=tk.YES, minwidth=50, width=100)
chat1.column('#2', stretch=tk.YES, minwidth=50, width=120)
chat1.column('#0', stretch=tk.YES, minwidth=50, width=400)
chat1.grid(row=2, column=2, columnspan=4, sticky='nsew')
def insert_value(self):
value = self.entry_val.get()
# Inserts data written in the entry box to the treeview widget when Enter button is pressed.
# Clears the Entry box, ready for another data entry.
self.entry_1.delete(0, 'end')
self.chat1.insert('WHAT SHOULD I GIVE AS AN ARGUMENT?')

Que dois-je passer comme argument?
Ou est treeview le droit widget pour cela, ou peut-on suggérer un widget adapté pour ce problème? grâce

  • Je veux juste savoir comment faire pour insérer un élément dans l'arborescence en utilisant le widget de saisie après avoir appuyé sur le bouton.J'ai d'autres colonnes parce que plus tard je vais inclure la date à laquelle cet élément a été ajouté.
  • Ce projet opensource peut beaucoup t'aider: github.com/talcs/tals_python_task_diary