Create and interact with a "settings window". You can a similar pair of functions to your code to add a "settings" feature.
()
| 67 | |
| 68 | |
| 69 | def settings_window(): |
| 70 | """ |
| 71 | Create and interact with a "settings window". You can a similar pair of functions to your |
| 72 | code to add a "settings" feature. |
| 73 | """ |
| 74 | |
| 75 | window = make_window() |
| 76 | current_theme = sg.theme() |
| 77 | |
| 78 | while True: |
| 79 | event, values = window.read() |
| 80 | if event in (sg.WINDOW_CLOSED, 'Exit'): |
| 81 | break |
| 82 | if event == 'Save': |
| 83 | # Save some of the values as user settings |
| 84 | settings['-input-'] = values['-IN-'] |
| 85 | settings['-theme-'] = values['-LISTBOX-'][0] |
| 86 | settings['-option1-'] = values['-CB1-'] |
| 87 | settings['-option2-'] = values['-CB2-'] |
| 88 | elif event == 'Settings Dictionary': |
| 89 | sg.popup(settings) |
| 90 | # if a listbox item is selected and if the theme was changed, then restart the window |
| 91 | if values['-LISTBOX-'] and values['-LISTBOX-'][0] != current_theme: |
| 92 | current_theme = values['-LISTBOX-'][0] |
| 93 | window.close() |
| 94 | window = make_window() |
| 95 | |
| 96 | |
| 97 | def save_previous_filename_demo(): |
no test coverage detected