I am trying to build GUI using tkinter for displaying csv file data and trying to add few columns which has manual entries,
But I am stuck at how to use StringVar for multiple entries and use trace method to apply changes when user update some value.
I tried to do many things using examples I found online but did not abel to do it.
I am able to create multiple stringvar but can't update it's value and when user enter something in entry widget and also I want to trace those stringvar object,
here is the code I wrote,
import pandas as pd
import tkinter as tk
import numpy as np
from tkinter import ttk
entries = {}
df = pd.read_csv(r'C:\Users\Saurabh\Desktop\Python\New folder\abc.csv')
df['Symbol'].replace(' ', np.nan, inplace=True)
df= df.dropna(subset=['Symbol'])
def search():
for (name,var) in entries.items():
print(f"{name}: {var.get()}")
f2 = tk.Tk()
for ind in df.index:
var = tk.StringVar()
entries[ind] = var
entry = ttk.Entry(f2 ,textvariable = var,width=25).grid(row=ind,column=2)
but = ttk.Button(f2,text="search",command=search())
but.grid(row=0,column=3)
f2.mainloop()
kindly help