(location)
| 19 | # May add ability to change theme from the user interface. For now forcing to constant |
| 20 | |
| 21 | def choose_theme(location): |
| 22 | layout = [[sg.Text(f'Current theme {sg.theme()}')], |
| 23 | [sg.Listbox(values=sg.theme_list(), size=(20, 20), key='-LIST-', enable_events=True)], |
| 24 | [sg.OK(), sg.Cancel()]] |
| 25 | |
| 26 | window = sg.Window('Look and Feel Browser', layout, location=location, keep_on_top=True) |
| 27 | old_theme = sg.theme() |
| 28 | while True: # Event Loop |
| 29 | event, values = window.read() |
| 30 | if event in (sg.WIN_CLOSED, 'Exit', 'OK', 'Cancel'): |
| 31 | break |
| 32 | sg.theme(values['-LIST-'][0]) |
| 33 | test_window = make_window(location=(location[0] - 200, location[1]), test_window=True) |
| 34 | test_window.read(close=True) |
| 35 | window.close() |
| 36 | |
| 37 | if event == 'OK' and values['-LIST-']: |
| 38 | sg.theme(values['-LIST-'][0]) |
| 39 | sg.user_settings_set_entry('-theme-', values['-LIST-'][0]) |
| 40 | return values['-LIST-'][0] |
| 41 | else: |
| 42 | sg.theme(old_theme) |
| 43 | return None |
| 44 | |
| 45 | |
| 46 | def make_window(location, test_window=False): |
no test coverage detected