From 04379b930d70442c4f61deb37c5914974939c4bc Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Wed, 17 Mar 2021 10:31:53 -0400 Subject: [PATCH] Added ability to use older versions of PySimpleGUI by trying sg.execute_editor and launching manually if it fails. Added quotes around __file__ when self-editing --- .../Browser_START_HERE_Demo_Programs_Browser.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py b/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py index 36a5aa3d..abd71977 100644 --- a/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py +++ b/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py @@ -123,6 +123,10 @@ def get_editor(): return user_editor +def using_local_editor(): + user_editor = sg.user_settings_get_entry('-editor program-', None) + return get_editor() == user_editor + def get_explorer(): """ @@ -507,10 +511,13 @@ def main(): sg.cprint('') sg.cprint(f'{full_filename}', c='white on purple') # if line != 1: - try: - sg.execute_editor(full_filename, line_number=int(line)) - except: + if using_local_editor(): execute_command_subprocess(editor_program, full_filename) + else: + try: + sg.execute_editor(full_filename, line_number=int(line)) + except: + execute_command_subprocess(editor_program, full_filename) # else: # sg.execute_editor(full_filename) else: @@ -543,7 +550,7 @@ def main(): editor_program = get_editor() sg.cprint(f'opening using {editor_program}:') sg.cprint(f'{__file__}', text_color='white', background_color='red', end='') - execute_command_subprocess(f'{editor_program}', f'{__file__}') + execute_command_subprocess(f'{editor_program}', f'"{__file__}"') elif event == '-FILTER-': new_list = [i for i in file_list if values['-FILTER-'].lower() in i.lower()] window['-DEMO LIST-'].update(new_list)