import PySimpleGUI as sg import os.path # First the window layout in 2 columns def optiwae_gui(obj): file_list_column = [ [ sg.Text("Type Section"), sg.In(size=(25, 1), enable_events=True, key="-FOLDER-"), sg.FolderBrowse(), ], [ sg.Listbox( values=[], enable_events=True, size=(40, 20), key="-FILE LIST-" ) ], ] variables_viewer_column = [ [sg.Text('x')], ] # ----- Full layout ----- lines_of_variables_0 = [] lines_of_variables_1 = [] lines_of_variables_2 = [] for count,(key, value) in enumerate(obj.items()): if count<= 10: lines_of_variables_0 += [[sg.Text(str(key) + '\n')]] if count >10: lines_of_variables_1+= [[sg.Text(str(key) +'\n')]] if count >20: lines_of_variables_2+= [[sg.Text(str(key) +'\n')]] layout = [ # sg.Column(file_list_column), [sg.Text('Enter Changes', size=(15, 1)), sg.InputText()], [sg.Submit(), sg.Cancel()], sg.Frame(layout= lines_of_variables_0, title=''), sg.VSeperator(), sg.Frame(layout=lines_of_variables_1, title=''), sg.VSeperator(), sg.Frame(layout=lines_of_variables_2, title=''), ] layout = [layout] window = sg.Window("Variables Viewer", layout) list_of_commands = [] while True: event, values = window.read() list_of_commands += [values[0]] if event == "Exit" or event == sg.WIN_CLOSED or event=='Cancel': window.close() break return list(set(list_of_commands)) # if event == "-FOLDER-": # # folder = values["-FOLDER-"] # # try: # # # Get list of files in folder # # file_list = os.listdir(folder) # # except: # # file_list = [] # # fnames = [ # # f # # for f in file_list # # if os.path.isfile(os.path.join(folder, f)) # # and f.lower().endswith((".png", ".gif")) # # ] # # window["-FILE LIST-"].update(fnames) # elif event == "-FILE LIST-": # A file was chosen from the listbox # # try: # # filename = os.path.join( # # values["-FOLDER-"], values["-FILE LIST-"][0] # # ) # # window["-TOUT-"].update(filename) # # window["-IMAGE-"].update(filename=filename) # # except: # # pass if __name__ == '__main__': k= {'x' :5, 'y':6} optiwae_gui(k)