From 2c3be600c3a17f676853fd42e00c0c31d6c674da Mon Sep 17 00:00:00 2001 From: Claudine Peyrat <88194877+claudinepeyrat06@users.noreply.github.com> Date: Sun, 22 Jun 2025 07:01:02 +0200 Subject: Claudine/unable element info copy (#3817) * firststeps * Update element_info.py * Update element_info.py * Update element_info.py add some help * make style... * rename a variable and fix a mistake * make headline nicer --- lib/extensions/element_info.py | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/element_info.py b/lib/extensions/element_info.py index ed879f43..3f2405fb 100644 --- a/lib/extensions/element_info.py +++ b/lib/extensions/element_info.py @@ -27,16 +27,17 @@ class ElementInfo(InkstitchExtension): self.list_items = [] self.max_stitch_lengths = [] self.min_stitch_lengths = [] + self.export_txt = "element_id\ttype\tmethod\tdimensions\tstitches\tjumps\tmax_stitch_length\tmin_stitch_length\n" next_elements = [None] if len(self.elements) > 1: next_elements = self.elements[1:] + next_elements previous_stitch_group = None for element, next_element in zip(self.elements, next_elements): - previous_stitch_group = self._element_info(element, previous_stitch_group, next_element) + text_export, previous_stitch_group = self._element_info(element, previous_stitch_group, next_element) + self.export_txt += text_export self._general_info() - - app = ElementInfoApp(self.list_items) + app = ElementInfoApp(self.list_items, self.export_txt) app.MainLoop() def _element_info(self, element, previous_stitch_group, next_element): @@ -46,18 +47,22 @@ class ElementInfo(InkstitchExtension): collapse_len=self.metadata['collapse_len_mm'], min_stitch_len=self.metadata['min_stitch_len_mm'] ) + label = element.node.label + element_id = element.node.get_id() self.list_items.append(ListItem( - name=f"{element.node.label} ({element.node.get_id()})", + name=f"{label} ({element_id})", value=stitch_groups[0].color, headline=True )) + element_name = element.element_name self.list_items.append(ListItem( name=_("Type"), - value=element.element_name + value=element_name )) if isinstance(element, FillStitch): fill_method = next((method.name for method in element._fill_methods if method.id == element.fill_method), "") + method = fill_method self.list_items.append(ListItem( name=_("Fill Method"), value=fill_method @@ -65,6 +70,7 @@ class ElementInfo(InkstitchExtension): if isinstance(element, SatinColumn): satin_method = next((method.name for method in element._satin_methods if method.id == element.satin_method), "") + method = satin_method self.list_items.append(ListItem( name=_("Satin Method"), value=satin_method @@ -72,14 +78,15 @@ class ElementInfo(InkstitchExtension): if isinstance(element, Stroke): stroke_method = next((method.name for method in element._stroke_methods if method.id == element.stroke_method), "") + method = stroke_method self.list_items.append(ListItem( name=_("Stroke Method"), value=stroke_method )) - + dimensions = "{:.2f} x {:.2f}".format(stitch_plan.dimensions_mm[0], stitch_plan.dimensions_mm[1]) self.list_items.append(ListItem( name=_("Dimensions (mm)"), - value="{:.2f} x {:.2f}".format(stitch_plan.dimensions_mm[0], stitch_plan.dimensions_mm[1]) + value=dimensions )) stitch_lengths = [] @@ -112,34 +119,40 @@ class ElementInfo(InkstitchExtension): name=_("Small stitches (removed)"), value=str(removed_stitches) )) - return stitch_groups[0] + return ("", stitch_groups[0]) stitches_per_group = "" if len(stitch_groups) > 1: stitches_per_group = f" ({', '.join([str(len(group.stitches)) for group in stitch_groups])})" + nb_stitches = str(stitch_plan.num_stitches - stitch_plan.num_jumps) + stitches_per_group self.list_items.append(ListItem( name=_("Stitches"), - value=str(stitch_plan.num_stitches - stitch_plan.num_jumps) + stitches_per_group + value=nb_stitches )) self.list_items.append(ListItem( name=_("Small stitches (removed)"), value=str(removed_stitches) )) + nb_jumps = str(stitch_plan.num_jumps - 1) self.list_items.append(ListItem( name=_("Jumps"), - value=str(stitch_plan.num_jumps - 1) + value=nb_jumps )) + max_stitch_length = "{:.2f}".format(max(stitch_lengths)) self.list_items.append(ListItem( name=_("Max stitch length"), - value="{:.2f}".format(max(stitch_lengths)) + value=max_stitch_length )) + min_stitch_length = "{:.2f}".format(min(stitch_lengths)) self.list_items.append(ListItem( name=_("Min stitch length"), - value="{:.2f}".format(min(stitch_lengths)) + value=min_stitch_length )) self.list_items.append(ListItem()) - return stitch_groups[0] + + text_export = f"{element_id}\t{element_name}\t{method}\t{dimensions}\t{nb_stitches}\t{nb_jumps}\t{max_stitch_length}\t{min_stitch_length}\n" + return (text_export, stitch_groups[0]) def _general_info(self): general_info_list_items = [] -- cgit v1.2.3