diff --git a/gui/cli_options.py b/gui/cli_options.py new file mode 100644 index 0000000..5a283be --- /dev/null +++ b/gui/cli_options.py @@ -0,0 +1,15 @@ +import os +import subprocess +from os.path import expanduser + +from gui.utils import open_file, get_configs_path + + +def install_program(): + print('>> '+' '.join(['pip', 'install', 'phulize']), end='\n\n') + process = subprocess.Popen(['pip', 'install', 'phulize'], stdout=subprocess.PIPE).communicate()[0] + print(process.decode('utf-8')) + + +def go_to_settings_files(): + return open_file(get_configs_path()) diff --git a/gui/layouts/options_layout.py b/gui/layouts/options_layout.py new file mode 100644 index 0000000..9ae3494 --- /dev/null +++ b/gui/layouts/options_layout.py @@ -0,0 +1,21 @@ +import textwrap + +import PySimpleGUI as sg + + +def get_options_layout(): + + ic_text_value = '"pip install phulize". Any console information regarding installing the CLI will be displayed in the "RUN" tab.' + wrapper = textwrap.TextWrapper(width=90) + install_help_text = wrapper.fill(text=ic_text_value) + + cli_options = [ + [sg.Button('Install CLI', tooltip='It will install this program\'s CLI if not installed already.')], + [sg.Text(install_help_text)], + [sg.Button('Open configurations folder', key='configs_folder')], + [sg.Text('', key='error_folder')], + ] + + return [ + [sg.Frame('CLI Advanced Options', layout=cli_options, font='Any 8', title_color='white', expand_x=True, expand_y=True)] + ] diff --git a/gui/main.py b/gui/main.py index c1226e6..5fa6fc3 100644 --- a/gui/main.py +++ b/gui/main.py @@ -1,7 +1,9 @@ import PySimpleGUI as sg from gui.api import run_resizer, edit_configs +from gui.cli_options import go_to_settings_files, install_program from gui.layouts.help_layout import get_help_layout +from gui.layouts.options_layout import get_options_layout from gui.layouts.run_layout import get_run_layout from gui.layouts.view_edit_layout import get_view_edit_layout from gui.utils import check_editable_config, open_file, list_configs, path_exists, get_icon_path @@ -14,6 +16,7 @@ def make_window(): [ sg.Tab('Run', get_run_layout()), sg.Tab('View/Edit', get_view_edit_layout()), + sg.Tab('Options', get_options_layout()), sg.Tab('Help', get_help_layout()) ] ]) @@ -72,6 +75,12 @@ def make_window(): if event == 'ORIGINAL': window['edit_folder'].update('_ORIGINAL') + if event == 'Install CLI': + install_program() + + if event == 'configs_folder' and not go_to_settings_files(): + window['error_folder'].update('ERROR: The settings folder does not exist yet. Add new Schedules.') + if event == 'conv_folder' and len(result) != 0: open_file(result['path']) if event == 'ori_folder' and len(result) != 0: diff --git a/gui/utils.py b/gui/utils.py index 86a6946..df2f6b8 100644 --- a/gui/utils.py +++ b/gui/utils.py @@ -26,9 +26,13 @@ def list_configs(): return list_of_configs -def get_configs_file_path(): +def get_configs_path(): home = expanduser("~") - return os.path.join(home, "phulize", "settings", "configs.yaml") + return os.path.join(home, "phulize", "settings") + + +def get_configs_file_path(): + return os.path.join(get_configs_path(), "configs.yaml") def open_file(path):