set encoding="utf8" so that can have special chars in files. ..otherwhise reads fail, Added quotes around strings to run,
This commit is contained in:
parent
2b6ce7590e
commit
9b656d35e7
|
@ -58,10 +58,7 @@ def get_demo_path():
|
||||||
|
|
||||||
def get_editor():
|
def get_editor():
|
||||||
try: # in case running with old version of PySimpleGUI that doesn't have a global PSG settings path
|
try: # in case running with old version of PySimpleGUI that doesn't have a global PSG settings path
|
||||||
if sg.pysimplegui_user_settings:
|
global_editor = sg.pysimplegui_user_settings.get('-editor program-')
|
||||||
global_editor = sg.pysimplegui_user_settings.get('-editor program-')
|
|
||||||
else:
|
|
||||||
global_editor = ''
|
|
||||||
except:
|
except:
|
||||||
global_editor = ''
|
global_editor = ''
|
||||||
|
|
||||||
|
@ -90,7 +87,7 @@ def find_in_file(string):
|
||||||
for file in demo_files:
|
for file in demo_files:
|
||||||
filename = os.path.join(demo_path, file)
|
filename = os.path.join(demo_path, file)
|
||||||
try:
|
try:
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r', encoding="utf8") as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if string in line.lower():
|
if string in line.lower():
|
||||||
file_list.append(file)
|
file_list.append(file)
|
||||||
|
@ -125,7 +122,7 @@ def settings_window():
|
||||||
event, values = window.read(close=True)
|
event, values = window.read(close=True)
|
||||||
if event == 'Ok':
|
if event == 'Ok':
|
||||||
sg.user_settings_set_entry('-demos folder-', values['-DEMOS-'])
|
sg.user_settings_set_entry('-demos folder-', values['-DEMOS-'])
|
||||||
new_editor = global_editor if not values['-EDITOR PROGRAM-'] else values['-EDITOR PROGRAM-']
|
new_editor = editor_program if not values['-EDITOR PROGRAM-'] else values['-EDITOR PROGRAM-']
|
||||||
sg.user_settings_set_entry('-editor program-', new_editor)
|
sg.user_settings_set_entry('-editor program-', new_editor)
|
||||||
new_theme = sg.theme_global() if values['-THEME-'] == '' else values['-THEME-']
|
new_theme = sg.theme_global() if values['-THEME-'] == '' else values['-THEME-']
|
||||||
sg.user_settings_set_entry('-theme-', new_theme)
|
sg.user_settings_set_entry('-theme-', new_theme)
|
||||||
|
@ -200,8 +197,8 @@ def main():
|
||||||
for file in values['-DEMO LIST-']:
|
for file in values['-DEMO LIST-']:
|
||||||
sg.cprint(f'Editing using {editor_program}', text_color='white', background_color='red', end='')
|
sg.cprint(f'Editing using {editor_program}', text_color='white', background_color='red', end='')
|
||||||
sg.cprint('')
|
sg.cprint('')
|
||||||
sg.cprint(f'{os.path.join(demo_path, file)}', text_color='white', background_color='purple')
|
sg.cprint(f'{os.path.join(demo_path, file)}', t='white', b='purple')
|
||||||
execute_command_subprocess(f'{editor_program}', os.path.join(demo_path, file))
|
execute_command_subprocess(f'{editor_program}', f'"{os.path.join(demo_path, file)}"')
|
||||||
elif event == 'Run':
|
elif event == 'Run':
|
||||||
sg.cprint('Running....', c='white on green', end='')
|
sg.cprint('Running....', c='white on green', end='')
|
||||||
sg.cprint('')
|
sg.cprint('')
|
||||||
|
@ -209,8 +206,8 @@ def main():
|
||||||
sg.cprint(os.path.join(demo_path, file),text_color='white', background_color='purple')
|
sg.cprint(os.path.join(demo_path, file),text_color='white', background_color='purple')
|
||||||
run_py(os.path.join(demo_path, file))
|
run_py(os.path.join(demo_path, file))
|
||||||
elif event.startswith('Edit Me'):
|
elif event.startswith('Edit Me'):
|
||||||
sg.cprint(f'opening using {editor_program}\nThis file - {__file__}', text_color='white', background_color='green', end='')
|
sg.cprint(f'opening using {editor_program}\nThis file - {__file__}', t='white', b='green', end='')
|
||||||
execute_command_subprocess(f'{editor_program}', __file__)
|
execute_command_subprocess(f'{editor_program}', f'"{__file__}"')
|
||||||
elif event == '-FILTER-':
|
elif event == '-FILTER-':
|
||||||
new_list = [i for i in demo_files if values['-FILTER-'].lower() in i.lower()]
|
new_list = [i for i in demo_files if values['-FILTER-'].lower() in i.lower()]
|
||||||
window['-DEMO LIST-'].update(new_list)
|
window['-DEMO LIST-'].update(new_list)
|
||||||
|
|
Loading…
Reference in New Issue