Merge pull request #4066 from PySimpleGUI/Dev-latest

Added ability to use older versions of PySimpleGUI by trying sg.execu…
This commit is contained in:
PySimpleGUI 2021-03-17 10:32:09 -04:00 committed by GitHub
commit 0b3562cf95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 4 deletions

View File

@ -123,6 +123,10 @@ def get_editor():
return user_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(): def get_explorer():
""" """
@ -507,6 +511,9 @@ def main():
sg.cprint('') sg.cprint('')
sg.cprint(f'{full_filename}', c='white on purple') sg.cprint(f'{full_filename}', c='white on purple')
# if line != 1: # if line != 1:
if using_local_editor():
execute_command_subprocess(editor_program, full_filename)
else:
try: try:
sg.execute_editor(full_filename, line_number=int(line)) sg.execute_editor(full_filename, line_number=int(line))
except: except:
@ -543,7 +550,7 @@ def main():
editor_program = get_editor() editor_program = get_editor()
sg.cprint(f'opening using {editor_program}:') sg.cprint(f'opening using {editor_program}:')
sg.cprint(f'{__file__}', text_color='white', background_color='red', end='') 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-': elif event == '-FILTER-':
new_list = [i for i in file_list if values['-FILTER-'].lower() in i.lower()] new_list = [i for i in file_list if values['-FILTER-'].lower() in i.lower()]
window['-DEMO LIST-'].update(new_list) window['-DEMO LIST-'].update(new_list)