MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / _choose_auto_watches

Method _choose_auto_watches

PySimpleGUI/PySimpleGUI.py:23987–24041  ·  view source on GitHub ↗
(self, my_locals)

Source from the content-addressed store, hash-verified

23985 '''
23986
23987 def _choose_auto_watches(self, my_locals):
23988 old_theme = theme()
23989 theme(_Debugger.DEBUGGER_MAIN_WINDOW_THEME)
23990 num_cols = 3
23991 output_text = ''
23992 num_lines = 2
23993 cur_col = 0
23994 layout = [[Text('Choose your "Auto Watch" variables', font='ANY 14', text_color='red')]]
23995 longest_line = max([len(key) for key in my_locals])
23996 line = []
23997 sorted_dict = {}
23998 for key in sorted(my_locals.keys()):
23999 sorted_dict[key] = my_locals[key]
24000 for key in sorted_dict:
24001 line.append(CB(key, key=key, size=(longest_line, 1),
24002 default=self.local_choices[key] if key in self.local_choices else False))
24003 if cur_col + 1 == num_cols:
24004 cur_col = 0
24005 layout.append(line)
24006 line = []
24007 else:
24008 cur_col += 1
24009 if cur_col:
24010 layout.append(line)
24011
24012 layout += [
24013 [Text('Custom Watch (any expression)'), Input(default_text=self.custom_watch, size=(40, 1), key='-CUSTOM_WATCH-')]]
24014 layout += [
24015 [Ok(), Cancel(), Button('Clear All'), Button('Select [almost] All', key='-AUTO_SELECT-')]]
24016
24017 window = Window('Choose Watches', layout, icon=PSG_DEBUGGER_LOGO, finalize=True, keep_on_top=True)
24018
24019 while True: # event loop
24020 event, values = window.read()
24021 if event in (None, 'Cancel', '-EXIT-'):
24022 break
24023 elif event == 'Ok':
24024 self.local_choices = values
24025 self.custom_watch = values['-CUSTOM_WATCH-']
24026 break
24027 elif event == 'Clear All':
24028 popup_quick_message('Cleared Auto Watches', auto_close=True, auto_close_duration=3, non_blocking=True, text_color='red', font='ANY 18')
24029 for key in sorted_dict:
24030 window.Element(key).Update(False)
24031 window.Element('-CUSTOM_WATCH-').Update('')
24032 elif event == 'Select All':
24033 for key in sorted_dict:
24034 window.Element(key).Update(False)
24035 elif event == '-AUTO_SELECT-':
24036 for key in sorted_dict:
24037 window.Element(key).Update(not key.startswith('_'))
24038
24039 # exited event loop
24040 window.Close()
24041 theme(old_theme)
24042
24043 '''
24044 ###### #######

Callers 1

Calls 11

readMethod · 0.95
themeFunction · 0.85
TextClass · 0.85
InputClass · 0.85
OkFunction · 0.85
CancelFunction · 0.85
ButtonClass · 0.85
WindowClass · 0.85
popup_quick_messageFunction · 0.85
UpdateMethod · 0.80
CloseMethod · 0.80

Tested by

no test coverage detected