sir i am new in python
i downloaded the code from the web
see the code
that run okay without any problem
from tkinter import *
from tkinter import ttk
inp = [{‘Currency’: ‘EUR’, ‘Volume’: ‘100’, ‘Country’: ‘SE’},
{‘Currency’: ‘GBR’, ‘Volume’: ‘200’, ‘Country’: ‘SE’},
{‘Currency’: ‘CAD’, ‘Volume’: ‘300’, ‘Country’: ‘SE’},
{‘Currency’: ‘EUR’, ‘Volume’: ‘400’, ‘Country’: ‘SE’},
{‘Currency’: ‘EUR’, ‘Volume’: ‘100’, ‘Country’: ‘DK’},
{‘Currency’: ‘GBR’, ‘Volume’: ‘200’, ‘Country’: ‘DK’},
{‘Currency’: ‘CAD’, ‘Volume’: ‘300’, ‘Country’: ‘DK’},
{‘Currency’: ‘EUR’, ‘Volume’: ‘400’, ‘Country’: ‘DK’},
]
class Application(Tk):
def init(self):
Tk.init(self)
self.title(“Volume”)
combofr = Frame(self)
combofr.pack(expand=True, fill=X)
self.tree = ttk.Treeview(self, show='headings')
columns = list(inp[0].keys())
self.filters = []
for col in columns:
name = ‘combo_’ + col
self.filters.append(name)
setattr(self, name, ttk.Combobox(combofr, values=[‘’] + sorted(set(x[col] for x in inp)), state=“readonly”))
getattr(self, name).pack(side=LEFT, expand=True, fill=X)
getattr(self, name).bind(‘<>’, self.select_from_filters)
self.tree["columns"] = columns
self.tree.pack(expand=TRUE, fill=BOTH)
for i in columns:
self.tree.column(i, anchor="w")
self.tree.heading(i, text=i, anchor="w")
for i, row in enumerate(inp):
self.tree.insert("", "end", text=i, values=list(row.values()))
def select_from_filters(self, event=None):
self.tree.delete(*self.tree.get_children())
all_filter = lambda x: all(x[f.split('_')[-1]] == getattr(self, f).get() or getattr(self, f).get() == '' for f in self.filters)
for row in inp:
if all_filter(row):
self.tree.insert("", "end", values=list(row.values()))
root = Application()
root.mainloop()
how to user this df in this code
df=pd.read_csv(‘d://data.csv’)now the code user the list
inp = [{‘Currency’: ‘EUR’, ‘Volume’: ‘100’, ‘Country’: ‘SE’},
{‘Currency’: ‘GBR’, ‘Volume’: ‘200’, ‘Country’: ‘SE’},
columns = list(inp[0].keys())
please give me idea how to use the pandas data frames in this code
for multicolumns data filter
the code download link
VSP
How to create a button or option which allows a user to filter a treeview based on a value in a column (python)?
python, tkinter, treeview
asked by VSP on 10:45AM - 08 Jan 20 UTC
I am waiting for your valuable reply