Hi All,
I wanted to update combo value dynamically, when browse file.The executed procedure as below:
1)click Browse button, select what you want file.
2)Combo control in GUI update item automatically.
The problem is how to enable FileBrowse event.
Any comment will highly appreciate!!
I wanted to update combo value dynamically, when browse file.The executed procedure as below:
1)click Browse button, select what you want file.
2)Combo control in GUI update item automatically.
The problem is how to enable FileBrowse event.
Any comment will highly appreciate!!
import PySimpleGUI as psg import pandas as pd import os working_directory = os.getcwd() TestItem=[] def read_file(csv_path): df=pd.read_csv(csv_path,header=1).drop([0,1]) allitems=df.columns.tolist() for item in allitems: if item.startswith(tuple(['DUT','Ref'])): TestItem.append(item) return TestItem psg.theme('SandyBeach') # define layout layout = [ [sg.Text(""),sg.Text('Selected File')], [sg.Text(""),sg.InputText(key="-FILE_PATH-",size=(120, 20)), sg.FilesBrowse(initial_folder=working_directory,file_types=[("CSV Files","*.csv")],enable_events=True,key='-sel-')], [sg.Combo(TestItem,key='-newitem-')], [sg.Text("",size=(1,0)),sg.OK('Check Master',key='-OK-'),sg.Exit(size=(5,0))]] window=psg.Window('Update Combo', layout) while True: event,value=window.read() if event in (sg.WIN_CLOSED,'Exit'): break elif event=='-sel-': csv_add = value["-FILE_PATH-"] Item = read_file(csv_add) window['-newitem-'].update(Item) elif event=='-OK-': sg.popup("Demo") window.close()