123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- 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)
|