diff --git a/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py b/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py index 0f8fcbbe..2c99ffae 100644 --- a/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py +++ b/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py @@ -5,6 +5,8 @@ import mmap, re import warnings import PySimpleGUI as sg + + """ PySimpleGUI Demo Program Browser @@ -329,6 +331,7 @@ def window_choose_line_to_edit(filename, full_filename, line_num_list): while True: event, values = window.read() if event in ('Cancel', sg.WIN_CLOSED): + line_chosen = None break # At this point we know a line was chosen line_chosen = event[1] @@ -443,8 +446,8 @@ def make_window(): options_at_bottom = sg.pin(sg.Column([[sg.CB('Verbose', enable_events=True, k='-VERBOSE-'), sg.CB('Show only first match in file', default=True, enable_events=True, k='-FIRST MATCH ONLY-'), - sg.CB('Find ignore case', default=True, enable_events=True, k='-IGNORE CASE-'), - sg.T('<---- NOTE: Only the "Verbose" setting is implemented at this time')]], pad=(0,0), k='-OPTIONS BOTTOM-')) + sg.CB('Find ignore case', default=True, enable_events=True, k='-IGNORE CASE-')]], + pad=(0,0), k='-OPTIONS BOTTOM-')) choose_folder_at_top = sg.pin(sg.Column([[sg.T('Click settings to set top of your tree or choose a previously chosen folder'), sg.Combo(sorted(sg.user_settings_get_entry('-folder names-', [])), default_value=sg.user_settings_get_entry('-demos folder-', ''), size=(50, 1), key='-FOLDERNAME-', enable_events=True, readonly=True)]], pad=(0,0), k='-FOLDER CHOOSE-')) @@ -497,10 +500,13 @@ def main(): full_filename, line = window_choose_line_to_edit(file, find_in_file.file_list_dict[file][0], find_in_file.file_list_dict[file][1]) else: full_filename, line = get_file_list_dict()[file], 1 - sg.cprint(f'Editing using {editor_program}', text_color='white', background_color='red', end='') - sg.cprint('') - sg.cprint(f'{full_filename}', text_color='white', background_color='purple') - sg.execute_editor(full_filename, line_number=int(line)) + if line is not None: + sg.cprint(f'Editing using {editor_program}', text_color='white', background_color='red', end='') + sg.cprint('') + sg.cprint(f'{full_filename}', c='white on purple') + sg.execute_editor(full_filename, line_number=int(line)) + else: + sg.cprint('Editing canclled') elif event == 'Run': sg.cprint('Running....', c='white on green', end='') sg.cprint('') @@ -639,5 +645,18 @@ if __name__ == '__main__': icon = b'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAAK/2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4NCjx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDA3IDEuMTM2ODgxLCAyMDEwLzA2LzEwLTE4OjExOjM1ICAgICAgICAiPg0KICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPg0KICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIiB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1wTU06RG9jdW1lbnRJRD0iRUM4REZFNUEyMEM0QjcwMzFBMjNBRDA4NENCNzZCODAiIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0iRUM4REZFNUEyMEM0QjcwMzFBMjNBRDA4NENCNzZCODAiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUVBNkIyNzA3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hbISOGRYnuxqOV8zaL9/TR+gYF98w96Qs3DQ3wA0HO4xmalctOq4JAee7Co53/D/z2BPwAlMRlLdQS6SQAAAABJRU5ErkJggg==' - +if __name__ == '__main__': + try: + version = sg.version + version_parts = version.split('.') + major_version, minor_version = int(version_parts[0]), int(version_parts[1]) + if major_version < 4 or minor_version < 35: + sg.popup('Warning - Your PySimpleGUI version is less then 4.35.0', + 'As a result, you will not be able to use the EDIT features of this program', + 'Please upgrade to at least 4.35.0', + f'You are currently running version:', + sg.version, + background_color='red', text_color='white') + except Exception as e: + print(f'** Warning Exception parsing version: {version} ** ', f'{e}') main() \ No newline at end of file