Skip to content

Commit

Permalink
[gui] add options tab
Browse files Browse the repository at this point in the history
  • Loading branch information
zaytiri committed Sep 23, 2023
1 parent d28b707 commit b5f5027
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
15 changes: 15 additions & 0 deletions gui/cli_options.py
Original file line number Diff line number Diff line change
@@ -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())
21 changes: 21 additions & 0 deletions gui/layouts/options_layout.py
Original file line number Diff line number Diff line change
@@ -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)]
]
9 changes: 9 additions & 0 deletions gui/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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())
]
])
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions gui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b5f5027

Please sign in to comment.