Runs the editor that was configured in the global settings and opens the file to a specific line number. Two global settings keys are used. '-editor program-' the command line used to startup your editor. It's set in the global settings window or by directly manipulating the PyS
(file_to_edit, line_number=None)
| 23269 | |
| 23270 | |
| 23271 | def execute_editor(file_to_edit, line_number=None): |
| 23272 | """ |
| 23273 | Runs the editor that was configured in the global settings and opens the file to a specific line number. |
| 23274 | Two global settings keys are used. |
| 23275 | '-editor program-' the command line used to startup your editor. It's set |
| 23276 | in the global settings window or by directly manipulating the PySimpleGUI settings object |
| 23277 | '-editor format string-' a string containing 3 "tokens" that describes the command that is executed |
| 23278 | <editor> <file> <line> |
| 23279 | :param file_to_edit: the full path to the file to edit |
| 23280 | :type file_to_edit: (str) |
| 23281 | :param line_number: optional line number to place the cursor |
| 23282 | :type line_number: (int) |
| 23283 | :return: Popen object |
| 23284 | :rtype: (subprocess.Popen) | None |
| 23285 | """ |
| 23286 | if file_to_edit is not None and len(file_to_edit) != 0 and file_to_edit[0] not in ('\"', "\'") and ' ' in file_to_edit: |
| 23287 | file_to_edit = '"' + file_to_edit + '"' |
| 23288 | pysimplegui_user_settings.load() # Refresh the settings just in case they've changed via another program |
| 23289 | editor_program = pysimplegui_user_settings.get('-editor program-', None) |
| 23290 | if editor_program is not None: |
| 23291 | format_string = pysimplegui_user_settings.get('-editor format string-', None) |
| 23292 | # if no format string, then just launch the editor with the filename |
| 23293 | if not format_string or line_number is None: |
| 23294 | sp = execute_command_subprocess(editor_program, file_to_edit) |
| 23295 | else: |
| 23296 | command = _create_full_editor_command(file_to_edit, line_number, format_string) |
| 23297 | # print('final command line = ', command) |
| 23298 | sp = execute_command_subprocess(editor_program, command) |
| 23299 | else: |
| 23300 | print('No editor has been configured in the global settings') |
| 23301 | sp = None |
| 23302 | return sp |
| 23303 | |
| 23304 | |
| 23305 | def execute_get_results(subprocess_id, timeout=None): |
no test coverage detected