Fix for case-mismatch. Made search string all lower. Changed how Linux python command is launched. Added defaults to User Settings.
This commit is contained in:
parent
a4d86304a8
commit
4b79837cb7
|
@ -30,7 +30,6 @@ import PySimpleGUI as sg
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_demo_git_files():
|
def get_demo_git_files():
|
||||||
"""
|
"""
|
||||||
Get the files in the demo and the GitHub folders
|
Get the files in the demo and the GitHub folders
|
||||||
|
@ -40,8 +39,8 @@ def get_demo_git_files():
|
||||||
:rtype: Tuple[List[str], List[str]]
|
:rtype: Tuple[List[str], List[str]]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
demo_path = sg.user_settings_get_entry('-demos folder-')
|
demo_path = sg.user_settings_get_entry('-demos folder-', '')
|
||||||
git_demo_path = sg.user_settings_get_entry('-github folder-')
|
git_demo_path = sg.user_settings_get_entry('-github folder-', '')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
git_demo_files = os.listdir(git_demo_path)
|
git_demo_files = os.listdir(git_demo_path)
|
||||||
|
@ -68,7 +67,7 @@ def find_in_file(string):
|
||||||
|
|
||||||
demo_path = sg.user_settings_get_entry('-demos folder-')
|
demo_path = sg.user_settings_get_entry('-demos folder-')
|
||||||
demo_files, git_files = get_demo_git_files()
|
demo_files, git_files = get_demo_git_files()
|
||||||
|
string = string.lower()
|
||||||
file_list = []
|
file_list = []
|
||||||
for file in demo_files:
|
for file in demo_files:
|
||||||
filename = os.path.join(demo_path, file)
|
filename = os.path.join(demo_path, file)
|
||||||
|
@ -95,11 +94,11 @@ def settings_window():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
layout = [[sg.T('Program Settings', font='DEFAIULT 18')],
|
layout = [[sg.T('Program Settings', font='DEFAIULT 18')],
|
||||||
[sg.T('Path to Demos', size=(20, 1)), sg.In(sg.user_settings_get_entry('-demos folder-'), k='-DEMOS-'), sg.FolderBrowse()],
|
[sg.T('Path to Demos', size=(20, 1)), sg.In(sg.user_settings_get_entry('-demos folder-', ''), k='-DEMOS-'), sg.FolderBrowse()],
|
||||||
[sg.T('Path to GitHub Folder', size=(20, 1)), sg.In(sg.user_settings_get_entry('-github folder-'), k='-GITHUB-'), sg.FolderBrowse()],
|
[sg.T('Path to GitHub Folder', size=(20, 1)), sg.In(sg.user_settings_get_entry('-github folder-', ''), k='-GITHUB-'), sg.FolderBrowse()],
|
||||||
[sg.T('Github Program', size=(20, 1)), sg.In(sg.user_settings_get_entry('-GitHub Program-'), k='-GITHUB PROGRAM-'), sg.FileBrowse()],
|
[sg.T('Github Program', size=(20, 1)), sg.In(sg.user_settings_get_entry('-GitHub Program-', ''), k='-GITHUB PROGRAM-'), sg.FileBrowse()],
|
||||||
[sg.T('Editor Program', size=(20, 1)), sg.In(sg.user_settings_get_entry('-Editor Program-'), k='-EDITOR PROGRAM-'), sg.FileBrowse()],
|
[sg.T('Editor Program', size=(20, 1)), sg.In(sg.user_settings_get_entry('-Editor Program-', ''), k='-EDITOR PROGRAM-'), sg.FileBrowse()],
|
||||||
[sg.Combo(sg.theme_list(), sg.user_settings_get_entry('-theme-'), k='-THEME-')],
|
[sg.Combo(sg.theme_list(), sg.user_settings_get_entry('-theme-', None), k='-THEME-')],
|
||||||
[sg.B('Ok'), sg.B('Cancel')],
|
[sg.B('Ok'), sg.B('Cancel')],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -148,7 +147,7 @@ def make_window():
|
||||||
]
|
]
|
||||||
|
|
||||||
# ----- Full layout -----
|
# ----- Full layout -----
|
||||||
ML_KEY = '-ML-' # Multline's key
|
ML_KEY = '-ML-' # Multline's key
|
||||||
|
|
||||||
layout = [[sg.vtop(sg.Column(left_col, element_justification='c')), sg.VSeperator(), sg.vtop(sg.Column(right_col, element_justification='c'))],
|
layout = [[sg.vtop(sg.Column(left_col, element_justification='c')), sg.VSeperator(), sg.vtop(sg.Column(right_col, element_justification='c'))],
|
||||||
[sg.HorizontalSeparator()],
|
[sg.HorizontalSeparator()],
|
||||||
|
@ -175,10 +174,10 @@ def main():
|
||||||
It will call the make_window function to create the window.
|
It will call the make_window function to create the window.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
demo_path = sg.user_settings_get_entry('-demos folder-')
|
demo_path = sg.user_settings_get_entry('-demos folder-', '')
|
||||||
git_demo_path = sg.user_settings_get_entry('-github folder-')
|
git_demo_path = sg.user_settings_get_entry('-github folder-', '')
|
||||||
github_program = sg.user_settings_get_entry('-GitHub Program-')
|
github_program = sg.user_settings_get_entry('-GitHub Program-', '')
|
||||||
editor_program = sg.user_settings_get_entry('-Editor Program-')
|
editor_program = sg.user_settings_get_entry('-Editor Program-', '')
|
||||||
demo_files, git_files = get_demo_git_files()
|
demo_files, git_files = get_demo_git_files()
|
||||||
|
|
||||||
window = make_window()
|
window = make_window()
|
||||||
|
@ -223,6 +222,7 @@ def main():
|
||||||
elif event == '-RUN INDIVIDUAL-':
|
elif event == '-RUN INDIVIDUAL-':
|
||||||
sg.user_settings_set_entry('-filenames-', list(set(sg.user_settings_get_entry('-filenames-', []) + [values['-FILENAME-'], ])))
|
sg.user_settings_set_entry('-filenames-', list(set(sg.user_settings_get_entry('-filenames-', []) + [values['-FILENAME-'], ])))
|
||||||
sg.user_settings_set_entry('-last filename-', values['-FILENAME-'])
|
sg.user_settings_set_entry('-last filename-', values['-FILENAME-'])
|
||||||
|
|
||||||
window['-FILENAME-'].update(values=list(set(sg.user_settings_get_entry('-filenames-', []))))
|
window['-FILENAME-'].update(values=list(set(sg.user_settings_get_entry('-filenames-', []))))
|
||||||
sg.cprint('Running Individual File...', c='white on purple')
|
sg.cprint('Running Individual File...', c='white on purple')
|
||||||
sg.cprint(values['-FILENAME-'], c='white on red')
|
sg.cprint(values['-FILENAME-'], c='white on red')
|
||||||
|
@ -251,14 +251,10 @@ def run(app_name, parm=''):
|
||||||
|
|
||||||
|
|
||||||
def run_py(pyfile, parms=None):
|
def run_py(pyfile, parms=None):
|
||||||
if sys.platform == 'linux':
|
|
||||||
cmd = 'python3'
|
|
||||||
else:
|
|
||||||
cmd = 'python'
|
|
||||||
if parms is not None:
|
if parms is not None:
|
||||||
execute_command_subprocess(cmd, pyfile, parms)
|
execute_command_subprocess('python', pyfile, parms)
|
||||||
else:
|
else:
|
||||||
execute_command_subprocess(cmd, pyfile)
|
execute_command_subprocess('python', pyfile)
|
||||||
|
|
||||||
|
|
||||||
def execute_command_subprocess(command, *args, wait=False):
|
def execute_command_subprocess(command, *args, wait=False):
|
||||||
|
@ -266,7 +262,7 @@ def execute_command_subprocess(command, *args, wait=False):
|
||||||
arg_string = ''
|
arg_string = ''
|
||||||
for arg in args:
|
for arg in args:
|
||||||
arg_string += ' ' + str(arg)
|
arg_string += ' ' + str(arg)
|
||||||
sp = subprocess.Popen([command + arg_string, ], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
sp = subprocess.Popen(['python3' + arg_string, ], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
else:
|
else:
|
||||||
expanded_args = ' '.join(args)
|
expanded_args = ' '.join(args)
|
||||||
sp = subprocess.Popen([command, expanded_args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
sp = subprocess.Popen([command, expanded_args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
Loading…
Reference in New Issue