MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / _refresh_main_debugger_window

Method _refresh_main_debugger_window

PySimpleGUI/PySimpleGUI.py:23771–23895  ·  view source on GitHub ↗
(self, mylocals, myglobals)

Source from the content-addressed store, hash-verified

23769 '''
23770
23771 def _refresh_main_debugger_window(self, mylocals, myglobals):
23772 if not self.watcher_window: # if there is no window setup, nothing to do
23773 return False
23774 event, values = self.watcher_window.read(timeout=1)
23775 if event in (None, 'Exit', '_EXIT_', '-EXIT-'): # EXIT BUTTON / X BUTTON
23776 try:
23777 self.watcher_window.close()
23778 except:
23779 pass
23780 self.watcher_window = None
23781 return False
23782 # ------------------------------- Process events from REPL Tab -------------------------------
23783 cmd = values['-REPL-'] # get the REPL entered
23784 # BUTTON - GO (NOTE - This button is invisible!!)
23785 if event == 'Go': # GO BUTTON
23786 self.watcher_window.Element('-REPL-').Update('')
23787 self.watcher_window.Element('-OUTPUT-').Update(">>> {}\n".format(cmd), append=True, autoscroll=True)
23788
23789 try:
23790 result = eval('{}'.format(cmd), myglobals, mylocals)
23791 except Exception as e:
23792 if sys.version_info[0] < 3:
23793 result = 'Not available in Python 2'
23794 else:
23795 try:
23796 result = exec('{}'.format(cmd), myglobals, mylocals)
23797 except Exception as e:
23798 result = 'Exception {}\n'.format(e)
23799
23800 self.watcher_window.Element('-OUTPUT-').Update('{}\n'.format(result), append=True, autoscroll=True)
23801 # BUTTON - DETAIL
23802 elif event.endswith('_DETAIL_'): # DETAIL BUTTON
23803 var = values['_VAR{}_'.format(event[4])]
23804 try:
23805 result = str(eval(str(var), myglobals, mylocals))
23806 except:
23807 result = ''
23808 old_theme = theme()
23809 theme(_Debugger.DEBUGGER_MAIN_WINDOW_THEME)
23810 popup_scrolled(str(values['_VAR{}_'.format(event[4])]) + '\n' + result, title=var, non_blocking=True, font=_Debugger.DEBUGGER_VARIABLE_DETAILS_FONT)
23811 theme(old_theme)
23812 # BUTTON - OBJ
23813 elif event.endswith('_OBJ_'): # OBJECT BUTTON
23814 var = values['_VAR{}_'.format(event[4])]
23815 try:
23816 result = ObjToStringSingleObj(mylocals[var])
23817 except Exception as e:
23818 try:
23819 result = eval('{}'.format(var), myglobals, mylocals)
23820 result = ObjToStringSingleObj(result)
23821 except Exception as e:
23822 result = '{}\nError showing object {}'.format(e, var)
23823 old_theme = theme()
23824 theme(_Debugger.DEBUGGER_MAIN_WINDOW_THEME)
23825 popup_scrolled(str(var) + '\n' + str(result), title=var, non_blocking=True, font=_Debugger.DEBUGGER_VARIABLE_DETAILS_FONT)
23826 theme(old_theme)
23827 # ------------------------------- Process Watch Tab -------------------------------
23828 # BUTTON - Choose Locals to see

Callers 1

_refresh_debuggerFunction · 0.80

Calls 9

_choose_auto_watchesMethod · 0.95
_display_all_varsMethod · 0.95
themeFunction · 0.85
popup_scrolledFunction · 0.85
popup_yes_noFunction · 0.85
UpdateMethod · 0.80
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected