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

Function choose_theme

DemoPrograms/Demo_Desktop_Widget_Count_To_A_Goal.py:271–293  ·  view source on GitHub ↗
(location)

Source from the content-addressed store, hash-verified

269GSIZE = (160, 160)
270
271def choose_theme(location):
272 layout = [[sg.Text(f'Current theme {sg.theme()}')],
273 [sg.Listbox(values=sg.theme_list(), size=(20, 20), key='-LIST-', enable_events=True)],
274 [sg.OK(), sg.Cancel()]]
275
276 window = sg.Window('Look and Feel Browser', layout, location=location, keep_on_top=True)
277 old_theme = sg.theme()
278 while True: # Event Loop
279 event, values = window.read()
280 if event in (sg.WIN_CLOSED, 'Exit', 'OK', 'Cancel'):
281 break
282 sg.theme(values['-LIST-'][0])
283 test_window=make_window(location=(location[0]-200, location[1]), test_window=True)
284 test_window.read(close=True)
285 window.close()
286
287 if event == 'OK' and values['-LIST-']:
288 sg.theme(values['-LIST-'][0])
289 sg.user_settings_set_entry('-theme-', values['-LIST-'][0])
290 return values['-LIST-'][0]
291 else:
292 sg.theme(old_theme)
293 return None
294
295def make_window(location, test_window=False):
296 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