MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / choose_theme

Function choose_theme

DemoPrograms/Demo_Desktop_Widget_Manual_Counter.py:21–43  ·  view source on GitHub ↗
(location)

Source from the content-addressed store, hash-verified

19# May add ability to change theme from the user interface. For now forcing to constant
20
21def 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
46def make_window(location, test_window=False):

Callers 1

mainFunction · 0.70

Calls 3

readMethod · 0.95
closeMethod · 0.95
make_windowFunction · 0.70

Tested by

no test coverage detected