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

Function choose_theme

DemoPrograms/Demo_Desktop_Widget_Days_Counter.py:31–53  ·  view source on GitHub ↗
(location)

Source from the content-addressed store, hash-verified

29UPDATE_FREQUENCY_MILLISECONDS = 1000*60*60 # update every hour
30
31def choose_theme(location):
32 layout = [[sg.Text(f'Current theme {sg.theme()}')],
33 [sg.Listbox(values=sg.theme_list(), size=(20, 20), key='-LIST-', enable_events=True)],
34 [sg.OK(), sg.Cancel()]]
35
36 window = sg.Window('Look and Feel Browser', layout, location=location, keep_on_top=True)
37 old_theme = sg.theme()
38 while True: # Event Loop
39 event, values = window.read()
40 if event in (sg.WIN_CLOSED, 'Exit', 'OK', 'Cancel'):
41 break
42 sg.theme(values['-LIST-'][0])
43 test_window=make_window(location=(location[0]-200, location[1]), test_window=True)
44 test_window.read(close=True)
45 window.close()
46
47 if event == 'OK' and values['-LIST-']:
48 sg.theme(values['-LIST-'][0])
49 sg.user_settings_set_entry('-theme-', values['-LIST-'][0])
50 return values['-LIST-'][0]
51 else:
52 sg.theme(old_theme)
53 return None
54
55def make_window(location, test_window=False):
56 title_font = sg.user_settings_get_entry('-title font-', 'Courier 8')

Callers 1

mainFunction · 0.70

Calls 3

readMethod · 0.95
closeMethod · 0.95
make_windowFunction · 0.70

Tested by

no test coverage detected