I'm new to Python. I have GUI with a Pandas table and a combobox (in the future more than one) to filter the table. What's the best way to update the table after filtered? Since I understand my question is basic, do you have any suggestion for a good course or book to use Pandastable in a Tkinter GUI? Please find attached my sample code Regards
import tkinter as tk
import pandas as pd
import numpy as np
from tkinter import ttk
from pandastable import Table
root = tk.Tk()
frame1 = tk.Frame(root)
frame1.pack(fill='both',expand=True)
frame2 = tk.Frame(root)
frame2.pack()
# function to get unique values
def unique(list1):
x = np.array(list1)
print(np.unique(x))
df = pd.DataFrame({
'logdate': ['1/1/2020','1/2/2022', '1/3/2022', '3/3/2021','5/13/2021','10/11/2019','1/5/2020'],
'state': ['oh','oh', 'oh', 'ar','mi','ma','ms'],
'provname': ['acme facility','123 healthcare', '123 healthcare','basic clinic','healthcare solutions','best clinic','one stop clinic'],
})
pt1 = Table(frame1, dataframe=df)
pt1.show()
# Create Combobox
n = tk.StringVar()
combobox1 = ttk.Combobox(frame2, width = 27, textvariable = n)
combobox1.pack()
# Adding combobox drop down list
combobox1['values'] = list(df['state'].unique())
def selection(event):
#valore=combobox1.get()
print('-------------')
dfx = df.loc[(df['state'] == combobox1.get())]
print(dfx)
combobox1.bind("<<ComboboxSelected>>", selection)
root.mainloop()