From de383504e0e1d3b0b42d87fc1b647f2a42b988c2 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Wed, 25 Jan 2023 07:57:50 -0500 Subject: [PATCH] Error handling for when no editor has been configured --- ...rowser_START_HERE_Demo_Programs_Browser.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py b/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py index 60150ca8..f7c4a84d 100644 --- a/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py +++ b/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py @@ -5,7 +5,7 @@ import warnings import PySimpleGUI as sg -__version__ = '1.12.0' +__version__ = '1.12.2' """ PySimpleGUI Demo Program Browser @@ -36,7 +36,7 @@ __version__ = '1.12.0' Versions: 1.8.0 - Addition of option to show ALL file types, not just Python files 1.12.0 - Fix for problem with spaces in filename and using an editor specified in the demo program settings - + 1.12.2 - Better error handling for no editor configured Copyright 2021, 2022 PySimpleGUI.org """ @@ -577,16 +577,16 @@ def main(): sg.cprint(f'Editing using {editor_program}', c='white on red', end='') sg.cprint('') sg.cprint(f'{full_filename}', c='white on purple') - # if line != 1: - if using_local_editor(): - sg.execute_command_subprocess(editor_program, f'"{full_filename}"') + if not get_editor(): + sg.popup_error_with_traceback('No editor has been configured', 'You need to configure an editor in order to use this feature', 'You can configure the editor in the Demo Brower Settings or the PySimpleGUI Global Settings') else: - try: - sg.execute_editor(full_filename, line_number=int(line)) - except: + if using_local_editor(): sg.execute_command_subprocess(editor_program, f'"{full_filename}"') - # else: - # sg.execute_editor(full_filename) + else: + try: + sg.execute_editor(full_filename, line_number=int(line)) + except: + sg.execute_command_subprocess(editor_program, f'"{full_filename}"') else: sg.cprint('Editing canceled') elif event == 'Run':