From 35e7bee95f68e201c438a4096635a79d83b4a88c Mon Sep 17 00:00:00 2001 From: Shalom-cmd Date: Sat, 14 Dec 2024 21:48:42 -0800 Subject: [PATCH 1/2] fixed the display of the output --- src/changewidthpage.py | 7 +++---- src/utils.py | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/changewidthpage.py b/src/changewidthpage.py index 47ef90e..9eb606b 100644 --- a/src/changewidthpage.py +++ b/src/changewidthpage.py @@ -43,7 +43,7 @@ def __init__(self, **kwargs): height=35, background_color=(1, 1, 1, 1), padding=5, - spacing=20 + spacing=10 ) input_fields = { "Project Measurements:": { # header @@ -173,9 +173,8 @@ def submit(self, instance): ) # Format the output cast_on, cast_off, row_count, adjustments = result # Unpack the result - formatted_result = f"[b]Cast on #[/b]: {cast_on}\n" - formatted_result += f"[b]Cast off #[/b]: {cast_off}\n" - formatted_result += f"[b]Total Row Count:[/b] {row_count}\n\n" # Adding row count display + formatted_result = f"[b]Cast on #[/b]: {cast_on} [b]Cast off #[/b]: {cast_off} [b]Total Row Count:[/b] {row_count}\n" + # Add "Row number count" header only if adjustments are not empty if adjustments: diff --git a/src/utils.py b/src/utils.py index 4cad400..f116a3c 100644 --- a/src/utils.py +++ b/src/utils.py @@ -6,6 +6,7 @@ import random import re import traceback +import os from uu import encode import numpy @@ -173,7 +174,7 @@ def __init__(self): pass def generate_number_form(self, input_fields, styles, layout, submit_handler): - scroll_view = ScrollView(size_hint=(1, 6)) + scroll_view = ScrollView(size_hint=(1, None), height=Window.height * 0.9) form_layout = GridLayout(cols=3, padding=styles.padding, spacing=[styles.spacing, 10], size_hint_y=None) form_layout.bind(minimum_height=form_layout.setter('height')) @@ -214,31 +215,36 @@ def calculate_tooltip_width(): text_input.bind(focus=lambda instance, value, tooltip=tooltip_label: setattr(tooltip, 'opacity', 1 if value else 0)) - def update_tooltips(*args): for tooltip in tooltips: new_width = calculate_tooltip_width() tooltip.width = new_width tooltip.text_size = (new_width, None) - Window.bind(on_resize=update_tooltips) scroll_view.add_widget(form_layout) layout.add_widget(scroll_view) - result = Label(text="Result", color=styles.header_color) + # Adjust result label position here: + # Adjust result label position here: + + + result = Label(text="Result", color=styles.header_color, size_hint=(None, None)) + result.width = Window.width * 0.8 # Ensure the width is within the screen width (adjust as needed) + result.height = styles.height # Set the height to match your desired height + result.pos_hint = {"center_y": 0.5, "right": 0.9} # Position as needed layout.add_widget(result) - submit_button = Button(text="Submit", size_hint=styles.size_hint, height=styles.height, - background_color=styles.background_color) + submit_button = Button(text="Submit", size_hint=(0.5, 0.5), height=styles.height * 0.2, + background_color=styles.background_color) + submit_button.pos_hint = {"left": 0} # Align the button to the left submit_button.bind(on_press=submit_handler) layout.add_widget(submit_button) return layout, text_inputs, result - # stitches - columns # all vars must be natural numbers # smul, srem - s % smul = srem @@ -307,6 +313,10 @@ def decode(self, input_string): # public, takes in 2d array pattern and passes to encoder to be saved as string in file def save(self, id, pattern): try: + directory = "saved_patterns" # make sure saved_patters dir exists + if not os.path.exists(directory): + os.makedirs(directory) + with open("saved_patterns/"+id+str(random.randint(0, 5))+".txt", "w") as file: file.write(self.encode(pattern)) except Exception as e: From dcf3a36fdfa343ca400d173929c70d2cee941e96 Mon Sep 17 00:00:00 2001 From: Shalom-cmd Date: Sat, 14 Dec 2024 21:52:05 -0800 Subject: [PATCH 2/2] fixed the results display --- src/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.py b/src/utils.py index f116a3c..d38caae 100644 --- a/src/utils.py +++ b/src/utils.py @@ -174,7 +174,7 @@ def __init__(self): pass def generate_number_form(self, input_fields, styles, layout, submit_handler): - scroll_view = ScrollView(size_hint=(1, None), height=Window.height * 0.9) + scroll_view = ScrollView(size_hint=(1, None), height=Window.height * 1) form_layout = GridLayout(cols=3, padding=styles.padding, spacing=[styles.spacing, 10], size_hint_y=None) form_layout.bind(minimum_height=form_layout.setter('height'))