From 5f60c3f24efcec9d2bd58721fa71c06f98ad5668 Mon Sep 17 00:00:00 2001 From: Kaalleen Date: Wed, 7 Sep 2022 07:34:42 +0200 Subject: [PATCH] no addNS --- bingo/bingo.py | 16 ++++-------- resources/grouped_clone_template.svg | 39 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/bingo/bingo.py b/bingo/bingo.py index a7dfde4..4dc54c7 100644 --- a/bingo/bingo.py +++ b/bingo/bingo.py @@ -27,12 +27,9 @@ from random import shuffle from inkex import (NSS, Boolean, GenerateExtension, Group, Line, TextElement, - Transform, Tspan, addNS, colors, errormsg) + Transform, Tspan, colors, errormsg) from inkex.localization import inkex_gettext as _ -INKSCAPE_LABEL = addNS('label', 'inkscape') -XLINK_HREF = addNS('href', 'xlink') - class BingoCardCreator(GenerateExtension): """Outputs bingo cards as a svg fragment""" @@ -55,7 +52,7 @@ def __init__(self, *args, **kwargs): self.num_color = colors.Color('#000000') self.render_grid = False self.stroke_width = 1 - self.free_spaces = '' + self.free_spaces = None def container_transform(self): return Transform(translate=(0, 0)) @@ -95,7 +92,6 @@ def generate(self): self.num_color = self.options.num_color self.render_grid = self.options.render_grid self.stroke_width = self.options.stroke_width - self.free_spaces = None # if num_range is smaller than the rows, reduce rows to num_range if self.num_range < self.rows: self.rows = self.num_range @@ -139,7 +135,6 @@ def generate(self): grid_group = self._render_grid() transform = self._get_transform(bingo_field, bingo_clone, bingo_group_transform) - number_group.set('transform', transform) if grid_group is not None: grid_group.set('transform', transform) @@ -167,7 +162,7 @@ def _load_area_params(self, bingo_field): if self.card_header == "none": self.card_header = "" except (TypeError, ValueError, colors.ColorError): - label = bingo_field.get(INKSCAPE_LABEL, '') + label = bingo_field.label el_id = bingo_field.get('id') errormsg(_(f'Please verify bingo attributes for {label}: {el_id}')) @@ -209,9 +204,8 @@ def _set_layer_label(self, layer): def _get_clone_origin(self, clone): # returns the origin of the clone and transform information for grouped clones bingo_group_transform = None - source_id = clone.get(XLINK_HREF)[1:] - xpath = f'.//*[@id="{source_id}"]' - bingo_field = self.document.xpath(xpath)[0] + bingo_field = clone.href + source_id = bingo_field.get_id() if bingo_field.tag_name == "g": xpath = ".//svg:rect[starts-with(@id,'bingo-area')]" bingo_field = bingo_field.xpath(xpath) diff --git a/resources/grouped_clone_template.svg b/resources/grouped_clone_template.svg index 348a992..3c32e3c 100644 --- a/resources/grouped_clone_template.svg +++ b/resources/grouped_clone_template.svg @@ -26,14 +26,14 @@ inkscape:document-units="mm" showgrid="false" inkscape:zoom="0.89333698" - inkscape:cx="230.03637" + inkscape:cx="100.18616" inkscape:cy="203.73051" inkscape:window-width="1920" inkscape:window-height="1011" inkscape:window-x="0" inkscape:window-y="32" inkscape:window-maximized="1" - inkscape:current-layer="g26104" /> + inkscape:current-layer="g59320" /> Bingo Card Creator + id="tspan21636">Bingo Card Creator Template sample file + id="tspan21640">Template sample file + id="tspan21644"> Changes can be applied to the Changes can be applied to the top left bingo area. + id="tspan21648">top left bingo area. + id="tspan21650"> Use the XML-Editor to explore Use the XML-Editor to explore the specific attributes of the the specific attributes of the white bingo-area rectangle). + id="tspan21656">white bingo-area rectangle). + id="tspan21658"> Run Extensions > Render > Run Extensions > Render > Bingo Card Creator to include Bingo Card Creator to include randomized numbers into each randomized numbers into each bingo area field. + id="tspan21666">bingo area field. + bingo-free="3.3" + bingo-star="false" />