Added last value chosen for combo, popup with dictionary info.

This commit is contained in:
PySimpleGUI 2020-11-13 11:54:39 -05:00
parent 3ef927cdfe
commit 9e4bf95b33
1 changed files with 9 additions and 3 deletions

View File

@ -11,9 +11,13 @@ import PySimpleGUI as sg
"""
def main():
sg.user_settings_filename(path='.') # The settings file will be in the same folder as this program
layout = [[sg.T('This is your layout')],
[sg.T('Enter or choose name'), sg.Combo(sorted(sg.user_settings_get_entry('-names-', [])), size=(20,1), k='-COMBO-')],
[sg.T('Enter or choose name'),
sg.Combo(values=sorted(sg.user_settings_get_entry('-names-', [])),
default_value=sg.user_settings_get_entry('-last name chosen-', None),
size=(20,1), k='-COMBO-')],
[sg.T('Remembers last value'), sg.In(sg.user_settings_get_entry('-input-', ''), k='-INPUT-')],
[sg.OK(), sg.Button('Exit')]]
@ -21,10 +25,12 @@ def main():
if event == 'OK':
sg.user_settings_set_entry('-names-', list(set(sg.user_settings_get_entry('-names-', []) + [values['-COMBO-'],])))
sg.user_settings_set_entry('-last name chosen-', values['-COMBO-'])
sg.user_settings_set_entry('-input-', values['-INPUT-'])
print(f"You chose {values['-COMBO-']}")
sg.popup(f"You chose {values['-COMBO-']} and input {values['-INPUT-']}",
'The settions dictionary:', sg.user_settings())
if __name__ == '__main__':
sg.user_settings_filename(path='.')
main()