Skip to content

Commit

Permalink
Merge pull request #3 from recoskyler/recoskyler-dev
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
recoskyler authored Jan 11, 2024
2 parents be71980 + 98e74d2 commit 8c0c46a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 30 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ Executable will be created for your platform (for MacOS if you run it on MacOS,
#### MacOS Executable

```bash
flet pack main.py --icon assets/icon.png --name SheetGPT --product-name SheetGPT --product-version v1.0.1 --copyright MIT --bundle-id com.recoskyler.sheetgpt --add-data "assets:assets"
flet pack main.py --icon assets/icon.png --name SheetGPT --product-name SheetGPT --product-version v1.0.2 --copyright MIT --bundle-id com.recoskyler.sheetgpt --add-data "assets:assets"
```

#### Windows Executable

```bat
flet pack main.py --icon assets\icon.png --name SheetGPT --product-name SheetGPT --product-version v1.0.1 --file-version v1.0.1 --file-description SheetGPT --copyright MIT --add-data "assets;assets"
flet pack main.py --icon assets\icon.png --name SheetGPT --product-name SheetGPT --product-version v1.0.2 --file-version v1.0.2 --file-description SheetGPT --copyright MIT --add-data "assets;assets"
```

#### Linux Executable
Expand Down
71 changes: 44 additions & 27 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
worksheet = None
result_book = None
result_sheet = None
result_placement = None
result_placement = "r"
input_pos = ""
cache = dict()
limit = 0
Expand Down Expand Up @@ -110,7 +110,7 @@ def reset_globals():
worksheet = None
result_book = None
result_sheet = None
result_placement = None
result_placement = "r"
input_pos = ""
cache = dict()
limit = 0
Expand Down Expand Up @@ -167,7 +167,7 @@ def process_item(current_pos, current_col, current_row, input_values):
input_hash = str(hash(frozenset(input_values)))
result_value = get_cell_value(worksheet=result_sheet, cell=(current_col + current_row))

if result_value == None or str(result_value).strip() == "" or not skip:
if result_value is None or str(result_value).strip() == "" or not skip:
answer = ""
processed_count = 0

Expand All @@ -183,7 +183,7 @@ def process_item(current_pos, current_col, current_row, input_values):
answer = res[0]
processed_count = res[1]

set_cell_value(worksheet=result_sheet, cell=(current_col + current_row), value=answer)
set_cell_value(worksheet=result_sheet, cell=(str(current_col) + str(current_row)), value=answer)

print("Answer: " + answer)

Expand Down Expand Up @@ -739,7 +739,7 @@ def output_placement_changed(e):
ft.dropdown.Option("Place on the next column")
],
col={"md": 4},
value="Place on the next row"
value="Place on the next row" if result_placement == "r" else "Place on the next column"
)

def api_key_changed(e):
Expand Down Expand Up @@ -876,6 +876,28 @@ def on_skip_changed(e):
on_change=on_skip_changed
)

def clear_fields(e):
reset_globals()

limit_field.value = limit
api_key_field.value = api_key
prompt_field.value = prompt
system_prompt_field.value = DEFAULT_SYSTEM_PROMPT
until_field.value = until
inputs_field.value = ",".join(inputs)
input_pos_field.value = input_pos
output_col_field.value = result_col
output_row_field.value = result_row
output_placement_dropdown.value = "Place on the next row"
model_dropdown.value = model
sheet_dropdown.value = None
input_text.value = "No input file selected"
output_text.value = "No output file selected"
skip_switch.value = skip

page.update()
check_validity()

def start_processing(e):
global file_path
global result_path
Expand Down Expand Up @@ -929,6 +951,8 @@ def start_processing(e):
sheet_dropdown.disabled = True
input_button.disabled = True
output_button.disabled = True
reset_button.visible = False
reset_button.disabled = True

page.update()

Expand Down Expand Up @@ -963,34 +987,18 @@ def start_processing(e):
api_key_field.disabled = False
prompt_field.disabled = False
system_prompt_field.disabled = False
until_field.disabled = True
until_field.disabled = False
inputs_field.disabled = False
input_pos_field.disabled = True
input_pos_field.disabled = False
output_col_field.disabled = False
output_row_field.disabled = False
output_placement_dropdown.disabled = False
model_dropdown.disabled = False
sheet_dropdown.disabled = True
sheet_dropdown.disabled = False
input_button.disabled = False
output_button.disabled = True

reset_globals()

limit_field.value = limit
api_key_field.value = api_key
prompt_field.value = prompt
system_prompt_field.value = DEFAULT_SYSTEM_PROMPT
until_field.value = until
inputs_field.value = ",".join(inputs)
input_pos_field.value = input_pos
output_col_field.value = result_col
output_row_field.value = result_row
output_placement_dropdown.value = "Place on the next row"
model_dropdown.value = model
sheet_dropdown.value = None
input_text.value = "No input file selected"
output_text.value = "No output file selected"
skip_switch.value = skip
output_button.disabled = False
reset_button.visible = True
reset_button.disabled = False

page.update()
check_validity()
Expand All @@ -1017,6 +1025,14 @@ def start_processing(e):
col={"md": 3}
)

reset_button = ft.ElevatedButton(
"Clear fields",
disabled=True,
on_click=clear_fields,
col={"md": 3},
visible=False
)

stop_button = ft.OutlinedButton(
"Stop processing",
disabled=True,
Expand Down Expand Up @@ -1129,6 +1145,7 @@ def start_processing(e):
[
stop_button,
process_button,
reset_button,
ft.Row(
[process_message],
col={"md": 8},
Expand Down
2 changes: 1 addition & 1 deletion spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from os.path import splitext
from shutil import copyfile

__all__ = ["load_input_workbook", "create_result_book"]
__all__ = ["load_input_workbook", "create_output_book", "generate_result_path"]

def load_input_workbook(file_path: str):
wb = None
Expand Down

0 comments on commit 8c0c46a

Please sign in to comment.