From d6df8084f4a0fe8c8e174ea230d158512bd8f094 Mon Sep 17 00:00:00 2001 From: Kaalleen Date: Thu, 24 Jun 2021 22:25:13 +0200 Subject: add start markers, add troubleshoot pattern warning and fix wxpython language issue --- lib/extensions/apply_satin_pattern.py | 44 +++++++++++++++++++++++++++++++++-- lib/extensions/base.py | 2 +- lib/extensions/lettering.py | 4 +++- lib/extensions/params.py | 4 +++- 4 files changed, 49 insertions(+), 5 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/apply_satin_pattern.py b/lib/extensions/apply_satin_pattern.py index 9da81075..47eb4d83 100644 --- a/lib/extensions/apply_satin_pattern.py +++ b/lib/extensions/apply_satin_pattern.py @@ -4,11 +4,12 @@ # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. import inkex +from lxml import etree +from ..elements import SatinColumn from ..i18n import _ -from ..svg.tags import INKSTITCH_ATTRIBS +from ..svg.tags import INKSTITCH_ATTRIBS, SVG_DEFS_TAG from .base import InkstitchExtension -from ..elements import SatinColumn class ApplySatinPattern(InkstitchExtension): @@ -31,9 +32,48 @@ class ApplySatinPattern(InkstitchExtension): for pattern in patterns: pattern.node.set(INKSTITCH_ATTRIBS['pattern'], satin_id) + self.set_marker(pattern.node) def get_satin_column(self): return list(filter(lambda satin: isinstance(satin, SatinColumn), self.elements))[0] def get_patterns(self): return list(filter(lambda satin: not isinstance(satin, SatinColumn), self.elements)) + + def set_marker(self, node): + document = node.getroottree().getroot() + xpath = ".//marker[@id='inkstitch-pattern-marker']" + pattern_marker = document.xpath(xpath) + if not pattern_marker: + # get or create def element + defs = document.find(SVG_DEFS_TAG) + if defs is None: + defs = etree.SubElement(document, SVG_DEFS_TAG) + + # insert marker + marker = """ + + + + + """ # noqa: E501 + defs.append(etree.fromstring(marker)) + + # attach marker to node + style = node.get('style', '').split(";") + import sys + print(style, file=sys.stderr) + style = [i for i in style if not i.startswith('marker-start')] + style.append('marker-start:url(#inkstitch-pattern-marker)') + node.set('style', ";".join(style)) diff --git a/lib/extensions/base.py b/lib/extensions/base.py index f23ec5e2..00d4a00d 100644 --- a/lib/extensions/base.py +++ b/lib/extensions/base.py @@ -173,7 +173,7 @@ class InkstitchExtension(inkex.Effect): pass elif (node.tag in EMBROIDERABLE_TAGS or is_clone(node)) and not node.get(INKSTITCH_ATTRIBS['pattern']): nodes.append(node) - elif troubleshoot and node.tag in NOT_EMBROIDERABLE_TAGS: + elif troubleshoot and (node.tag in NOT_EMBROIDERABLE_TAGS or node.get(INKSTITCH_ATTRIBS['pattern'])): nodes.append(node) return nodes diff --git a/lib/extensions/lettering.py b/lib/extensions/lettering.py index e55365c6..cf627fe5 100644 --- a/lib/extensions/lettering.py +++ b/lib/extensions/lettering.py @@ -31,9 +31,11 @@ class LetteringFrame(wx.Frame): def __init__(self, *args, **kwargs): # This is necessary because of https://github.com/inkstitch/inkstitch/issues/1186 - if sys.platform.startswith('win'): + if sys.platform.startswith('win32'): import locale locale.setlocale(locale.LC_ALL, "C") + lc = wx.Locale() + lc.Init(wx.LANGUAGE_DEFAULT) # begin wxGlade: MyFrame.__init__ self.group = kwargs.pop('group') diff --git a/lib/extensions/params.py b/lib/extensions/params.py index 40494ec7..7775aed1 100644 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -331,9 +331,11 @@ class ParamsTab(ScrolledPanel): class SettingsFrame(wx.Frame): def __init__(self, *args, **kwargs): # This is necessary because of https://github.com/inkstitch/inkstitch/issues/1186 - if sys.platform.startswith('win'): + if sys.platform.startswith('win32'): import locale locale.setlocale(locale.LC_ALL, "C") + lc = wx.Locale() + lc.Init(wx.LANGUAGE_DEFAULT) # begin wxGlade: MyFrame.__init__ self.tabs_factory = kwargs.pop('tabs_factory', []) -- cgit v1.2.3