I have created gui for entry using tkinter in tabular form.
In this gui, I have used labels, Entry and Optionmenu. I can load and enter my data easily. But the problem is that there are hundreds of such records. Due to which (I think) tkinter gui takes time to load and lags while scrolling & entering data.
So, I used tkinter Treeview to load my large data which it loads and shows comfortably.
But I want to make changes in any desired row of my record which I could achieve by adding entry and optionmenu widgets in treeview if I were able to.
How can I add entry and optionmenu widgets in Amount
and Paid(Y/N)
column respectively ?
Here is the simplified code for the gui ::
import tkinter as tk
import tkinter.ttk as ttk
def DesiredTableInTreeView():
ewindow = tk.Toplevel(window)
ewindow.title("Desired Table in Treeview Form ")
ewindow.geometry("250x250+450+150") # Width x Height
PaidStatus=['Y', 'N']
for i in range(len(EntryData)):
data=EntryData[i]
sno = ttk.Label(ewindow, text = str(i+1), width=4).grid(row=i,column=0)
ids = ttk.Label(ewindow, text = data[1], width=8).grid(row=i,column=1)
name = ttk.Label(ewindow, text = data[2], width=12).grid(row=i,column=2)
amountEntry = tk.Entry(ewindow, width=6 )
amountEntry.insert(tk.END, data[3])
amountEntry.grid(row=i,column=3)
PaidVar = tk.StringVar()
Paid = ttk.OptionMenu(ewindow, PaidVar, data[4] , *PaidStatus)
Paid.grid(row=i,column=4)
window = tk.Tk()
window.title("Enter Data ")
window.geometry("250x200+150+150") # Width x Height
Heading = [ 'SNo.', 'Id' ,'Name', 'Amount', 'Paid(Y/N)']
EntryData = [ (1 , 23563, 'Arial' , 5000, 'Y' ),
(2 , 23570, 'John' , 15000, 'N' ),
(3 , 23571, 'Ava' , 300, 'Y' ),
(4 , 23573, 'Eric' , 6000, 'N' ),
(5 , 23575, 'Ross' , 5000, 'Y' ),
(6 , 23576, 'Jack' , 350, 'Y' ),
(7 , 23577, 'Bill' , 1000, 'N' ),
(8 , 23580, 'Rob' , 6050, 'Y' )
]
tv = ttk.Treeview(window, show='headings', columns=tuple([str(i) for i in range(1,6)]) ) # , selectmode='extended'
tv.pack(side=tk.LEFT,fill='both', expand='yes')
for i in range(len(Heading)):
tv.heading(str(i+1), text=Heading[i])
tv.column(str(i+1), width=45, stretch=tk.NO)
for i in range(len(EntryData)):
tv.insert("", 'end', values=EntryData[i] )
DesiredTableInTreeView()
window.mainloop()