Added last value chosen for combo, popup with dictionary info.
This commit is contained in:
parent
3ef927cdfe
commit
9e4bf95b33
|
@ -11,9 +11,13 @@ import PySimpleGUI as sg
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def main():
|
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')],
|
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.T('Remembers last value'), sg.In(sg.user_settings_get_entry('-input-', ''), k='-INPUT-')],
|
||||||
[sg.OK(), sg.Button('Exit')]]
|
[sg.OK(), sg.Button('Exit')]]
|
||||||
|
|
||||||
|
@ -21,10 +25,12 @@ def main():
|
||||||
|
|
||||||
if event == 'OK':
|
if event == 'OK':
|
||||||
sg.user_settings_set_entry('-names-', list(set(sg.user_settings_get_entry('-names-', []) + [values['-COMBO-'],])))
|
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-'])
|
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__':
|
if __name__ == '__main__':
|
||||||
sg.user_settings_filename(path='.')
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue