Support for double-clicking filenames - Choose the action from the settings
This commit is contained in:
parent
ada515fa72
commit
5f6857571d
|
@ -3,6 +3,7 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import mmap, re
|
import mmap, re
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
|
|
||||||
|
@ -434,7 +435,7 @@ def make_window():
|
||||||
|
|
||||||
|
|
||||||
left_col = sg.Column([
|
left_col = sg.Column([
|
||||||
[sg.Listbox(values=get_file_list(), select_mode=sg.SELECT_MODE_EXTENDED, size=(50,20), key='-DEMO LIST-')],
|
[sg.Listbox(values=get_file_list(), select_mode=sg.SELECT_MODE_EXTENDED, size=(50,20), bind_return_key=True, key='-DEMO LIST-')],
|
||||||
[sg.Text('Filter (F1):', tooltip=filter_tooltip), sg.Input(size=(25, 1), enable_events=True, key='-FILTER-', tooltip=filter_tooltip),
|
[sg.Text('Filter (F1):', tooltip=filter_tooltip), sg.Input(size=(25, 1), enable_events=True, key='-FILTER-', tooltip=filter_tooltip),
|
||||||
sg.T(size=(15,1), k='-FILTER NUMBER-')],
|
sg.T(size=(15,1), k='-FILTER NUMBER-')],
|
||||||
[sg.Button('Run'), sg.B('Edit'), sg.B('Clear'), sg.B('Open Folder')],
|
[sg.Button('Run'), sg.B('Edit'), sg.B('Clear'), sg.B('Open Folder')],
|
||||||
|
@ -476,10 +477,6 @@ def make_window():
|
||||||
window.bind('<F1>', '-FOCUS FILTER-')
|
window.bind('<F1>', '-FOCUS FILTER-')
|
||||||
window.bind('<F2>', '-FOCUS FIND-')
|
window.bind('<F2>', '-FOCUS FIND-')
|
||||||
window.bind('<F3>', '-FOCUS RE FIND-')
|
window.bind('<F3>', '-FOCUS RE FIND-')
|
||||||
if sg.user_settings_get_entry('-dclick runs-'):
|
|
||||||
window['-DEMO LIST-'].bind('<Double-Button-1>', '+Run+')
|
|
||||||
elif sg.user_settings_get_entry('-dclick edits-'):
|
|
||||||
window['-DEMO LIST-'].bind('<Double-Button-1>', '+Edit+')
|
|
||||||
if not advanced_mode():
|
if not advanced_mode():
|
||||||
window['-FOLDER CHOOSE-'].update(visible=False)
|
window['-FOLDER CHOOSE-'].update(visible=False)
|
||||||
window['-RE COL-'].update(visible=False)
|
window['-RE COL-'].update(visible=False)
|
||||||
|
@ -512,7 +509,12 @@ def main():
|
||||||
counter += 1
|
counter += 1
|
||||||
if event in (sg.WINDOW_CLOSED, 'Exit'):
|
if event in (sg.WINDOW_CLOSED, 'Exit'):
|
||||||
break
|
break
|
||||||
if event == 'Edit' or event.endswith('+Edit+'):
|
if event == '-DEMO LIST-': # if double clicked (used the bind return key parm)
|
||||||
|
if sg.user_settings_get_entry('-dclick runs-'):
|
||||||
|
event = 'Run'
|
||||||
|
elif sg.user_settings_get_entry('-dclick edits-'):
|
||||||
|
event = 'Edit'
|
||||||
|
if event == 'Edit':
|
||||||
editor_program = get_editor()
|
editor_program = get_editor()
|
||||||
for file in values['-DEMO LIST-']:
|
for file in values['-DEMO LIST-']:
|
||||||
if find_in_file.file_list_dict is not None:
|
if find_in_file.file_list_dict is not None:
|
||||||
|
@ -534,15 +536,15 @@ def main():
|
||||||
# else:
|
# else:
|
||||||
# sg.execute_editor(full_filename)
|
# sg.execute_editor(full_filename)
|
||||||
else:
|
else:
|
||||||
sg.cprint('Editing canclled')
|
sg.cprint('Editing canceled')
|
||||||
elif event == 'Run' or event.endswith('+Run+'):
|
elif event == 'Run':
|
||||||
sg.cprint('Running....', c='white on green', end='')
|
sg.cprint('Running....', c='white on green', end='')
|
||||||
sg.cprint('')
|
sg.cprint('')
|
||||||
for file in values['-DEMO LIST-']:
|
for file in values['-DEMO LIST-']:
|
||||||
file_to_run = str(file_list_dict[file])
|
file_to_run = str(file_list_dict[file])
|
||||||
sg.cprint(file_to_run,text_color='white', background_color='purple')
|
sg.cprint(file_to_run,text_color='white', background_color='purple')
|
||||||
try:
|
try:
|
||||||
sp = execute_py_file(f'{file_to_run}', pipe_output=values['-WAIT-'])
|
sp = execute_py_file(file_to_run, pipe_output=values['-WAIT-'])
|
||||||
except TypeError:
|
except TypeError:
|
||||||
sg.cprint('Consider upgrading to a newer PySimpleGUI.... 4.37.0 has better execution controls', c='white on red')
|
sg.cprint('Consider upgrading to a newer PySimpleGUI.... 4.37.0 has better execution controls', c='white on red')
|
||||||
sp = execute_py_file_with_pipe_output(f'{file_to_run}', pipe_output=values['-WAIT-'])
|
sp = execute_py_file_with_pipe_output(f'{file_to_run}', pipe_output=values['-WAIT-'])
|
||||||
|
|
Loading…
Reference in New Issue