This is my sample code. I want the elements entered in the record to be inserted into the tree image when I press the enter button. I am new to python and tkinter, and there are not many problems with 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()
What should I pass as an argument? Or is there a tree for the right widget for this, or can someone suggest a widget suitable for this problem? thanks