diff --git a/DemoPrograms/Demo_Debugger_ImWatchingYou.py b/DemoPrograms/Demo_Debugger_ImWatchingYou.py index 6483852c..29df0312 100644 --- a/DemoPrograms/Demo_Debugger_ImWatchingYou.py +++ b/DemoPrograms/Demo_Debugger_ImWatchingYou.py @@ -28,7 +28,7 @@ layout = [ sg.Radio('c', 1, key='_R3_')], [sg.Combo(['c1', 'c2', 'c3'], size=(6, 3), key='_COMBO_')], [sg.Output(size=(50, 6))], - [sg.Ok(), sg.Exit(), sg.Button('Debugg'), sg.Button('Popout')], + [sg.Ok(), sg.Exit(), sg.Button('Debug'), sg.Button('Popout')], ] window = sg.Window('This is your Application Window', layout) @@ -46,7 +46,7 @@ while True: # Your Event Loop elif event == 'Ok': print('You clicked Ok.... this is where print output goes') imwatchingyou.show_debugger_popout_window() # STEP 2 also - elif event == 'Debugg': + elif event == 'Debug': imwatchingyou.show_debugger_window() # STEP 2 elif event == 'Popout': imwatchingyou.show_debugger_popout_window() # STEP 2 diff --git a/DemoPrograms/Demo_Debugger_Integration.py b/DemoPrograms/Demo_Debugger_Integration.py deleted file mode 100644 index 29df0312..00000000 --- a/DemoPrograms/Demo_Debugger_Integration.py +++ /dev/null @@ -1,60 +0,0 @@ -import PySimpleGUI as sg -import imwatchingyou # STEP 1 - -""" - Demo program that shows you how to integrate the PySimpleGUI Debugger - into your program. - This particular program is a GUI based program simply to make it easier for you to interact and change - things. - - In this example, the debugger is not started initiallly. You click the "Debug" button to launch it - There are THREE steps, and they are copy and pastes. - 1. At the top of your app to debug add - import imwatchingyou - 2. When you want to show a debug window, call one of two functions: - imwatchingyou.show_debug_window() - imwatchingyou.show_popout_window() - 3. You must find a location in your code to "refresh" the debugger. Some loop that's executed often. - In this loop add this call: - imwatchingyou.refresh() -""" - -layout = [ - [sg.T('A typical PSG application')], - [sg.In(key='_IN_')], - [sg.T(' ', key='_OUT_', size=(30, 1))], - [sg.Radio('a', 1, key='_R1_'), - sg.Radio('b', 1, key='_R2_'), - sg.Radio('c', 1, key='_R3_')], - [sg.Combo(['c1', 'c2', 'c3'], size=(6, 3), key='_COMBO_')], - [sg.Output(size=(50, 6))], - [sg.Ok(), sg.Exit(), sg.Button('Debug'), sg.Button('Popout')], -] - -window = sg.Window('This is your Application Window', layout) - -counter = 0 -timeout = 100 - -# Start the program with the popout window showing so you can immediately start debugging! -imwatchingyou.show_debugger_popout_window() - -while True: # Your Event Loop - event, values = window.Read(timeout=timeout) - if event in (None, 'Exit'): - break - elif event == 'Ok': - print('You clicked Ok.... this is where print output goes') - imwatchingyou.show_debugger_popout_window() # STEP 2 also - elif event == 'Debug': - imwatchingyou.show_debugger_window() # STEP 2 - elif event == 'Popout': - imwatchingyou.show_debugger_popout_window() # STEP 2 - counter += 1 - # to prove window is operating, show the input in another area in the window. - window.Element('_OUT_').Update(values['_IN_']) - - # don't worry about the "state" of things, just call this function "frequently" - imwatchingyou.refresh_debugger() # STEP 3 - refresh debugger - -window.Close() diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 19bb15d1..2aca3126 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -3536,12 +3536,13 @@ class ErrorElement(Element): super().__init__(ELEM_TYPE_ERROR, key=key) return - def Update(self, *args, **kwargs): - PopupError('Keyword error in Update', - 'You need to stop this madness and check your spelling', - 'Bad key = {}'.format(self.Key), - 'Your bad line of code may resemble this:', - 'window.FindElement("{}")'.format(self.Key)) + def Update(self, silent_on_error=True, *args, **kwargs): + if not silent_on_error: + PopupError('Keyword error in Update', + 'You need to stop this madness and check your spelling', + 'Bad key = {}'.format(self.Key), + 'Your bad line of code may resemble this:', + 'window.FindElement("{}")'.format(self.Key)) return self def Get(self): @@ -3980,14 +3981,13 @@ class Window: # element = _FindElementFromKeyInSubForm(self, key) if element is None: if not silent_on_error: - print('*** WARNING = FindElement did not find the key. Please check your key\'s spelling ***') + print( + '*** WARNING = FindElement did not find the key. Please check your key\'s spelling key = %s ***' % key) PopupError('Keyword error in FindElement Call', 'Bad key = {}'.format(key), 'Your bad line of code may resemble this:', 'window.FindElement("{}")'.format(key)) - return ErrorElement(key=key) - else: - return None + return ErrorElement(key=key) return element Element = FindElement # Shortcut function @@ -5064,7 +5064,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): # Determine Element size element_size = element.Size if (element_size == (None, None) and element_type not in ( - ELEM_TYPE_BUTTON, ELEM_TYPE_BUTTONMENU)): # user did not specify a size + ELEM_TYPE_BUTTON, ELEM_TYPE_BUTTONMENU)): # user did not specify a size element_size = toplevel_form.DefaultElementSize elif (element_size == (None, None) and element_type in (ELEM_TYPE_BUTTON, ELEM_TYPE_BUTTONMENU)): element_size = toplevel_form.DefaultButtonElementSize @@ -5168,7 +5168,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): # ---===--- LABEL widget create and place --- # stringvar = tk.StringVar() element.TKStringVar = stringvar - stringvar.set(display_text) + stringvar.set(str(display_text)) if auto_size_text: width = 0 if element.Justification is not None: @@ -5179,13 +5179,11 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): justification = DEFAULT_TEXT_JUSTIFICATION justify = tk.LEFT if justification == 'left' else tk.CENTER if justification == 'center' else tk.RIGHT anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE - # tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, - # justify=justify, bd=border_depth, font=font) + tktext_label = element.Widget = tk.Label(tk_row_frame, textvariable=stringvar, width=width, - height=height, - justify=justify, bd=border_depth, font=font) + height=height, justify=justify, bd=border_depth, font=font) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS - wraplen = tktext_label.winfo_reqwidth() + 40 # width of widget in Pixels + wraplen = tktext_label.winfo_reqwidth() - 10 # width of widget in Pixels if not auto_size_text and height == 1: wraplen = 0 tktext_label.configure(anchor=anchor, wraplen=wraplen) # set wrap to width of widget @@ -7806,9 +7804,11 @@ def PopupGetFile(message, title=None, default_path='', default_extension='', sav filename = tk.filedialog.asksaveasfilename(filetypes=file_types, defaultextension=default_extension) # show the 'get file' dialog box elif multiple_files: - filename = tk.filedialog.askopenfilenames(filetypes=file_types, defaultextension=default_extension) # show the 'get file' dialog box + filename = tk.filedialog.askopenfilenames(filetypes=file_types, + defaultextension=default_extension) # show the 'get file' dialog box else: - filename = tk.filedialog.askopenfilename(filetypes=file_types, defaultextension=default_extension) # show the 'get files' dialog box + filename = tk.filedialog.askopenfilename(filetypes=file_types, + defaultextension=default_extension) # show the 'get files' dialog box root.destroy() if Window.NumOpenWindows == 1: