Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/changewidthpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 17 additions & 7 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import random
import re
import traceback
import os
from uu import encode

import numpy
Expand Down Expand Up @@ -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 * 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'))

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down