First of all, PySimpleGUI is magnificent!!
How to save the last selected file in sg.filebrowser so that the next time I run the script, this file will be the default value in default_text from sg.InputText?
Today I have this:
import PySimpleGUI as sg
layout = [
[sg.Text('Selecione o Arquivo Executável na Pasta de Instalação '), sg.InputText(default_text='' key='EXE_SPED'), sg.FileBrowse(button_text='Selecione')],
[sg.Text('Selecione a Pasta Com os Arquivos .REC e .TXT '), sg.InputText(key='PASTA_ARQUI'), sg.FolderBrowse(button_text='Selecione')],
[ sg.Button('OK'), sg.Button('CANCELAR')]]
Window = sg.Window('Print Folder -- Versão 1.0', layout=layout)
while True:
event, values = Window.read()
if event in (None, 'CANCELAR'): # if user closes window or clicks cancel
break
if event == 'OK':
print(Pvalues['EXE_SPED'])
Imagine that I selected the file C: \ Users \ Felipe \ Downloads \ Output.txt, clicked ok, the program was executed and then closed the window. So I opened the program again and will it be like this:
import PySimpleGUI as sg
layout = [
[sg.Text('Selecione o Arquivo Executável na Pasta de Instalação '), sg.InputText(default_text='C: \ Users \ Felipe \ Downloads \ Output.txt' key='EXE_SPED'), sg.FileBrowse(button_text='Selecione')],
[sg.Text('Selecione a Pasta Com os Arquivos .REC e .TXT '), sg.InputText(key='PASTA_ARQUI'), sg.FolderBrowse(button_text='Selecione')],
[ sg.Button('OK'), sg.Button('CANCELAR')]]
Window = sg.Window('Print Folder -- Versão 1.0', layout=layout)
while True:
event, values = Window.read()
if event in (None, 'CANCELAR'): # if user closes window or clicks cancel
break
if event == 'OK':
print(values['EXE_SPED'])
Is there a way to do this without having to save the value in another file (like a txt for example)?