summaryrefslogtreecommitdiff
path: root/lib/extensions/palette_to_text.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-06-30 22:49:18 +0200
committerGitHub <noreply@github.com>2024-06-30 22:49:18 +0200
commite52886a64a4e76c3fdc49df95c85655da3c4f7f4 (patch)
tree88a4edee630df0947553ced79fb6eb9dc510ccea /lib/extensions/palette_to_text.py
parent7c06dee44ac7951a5db406eb829100a5bc3e5887 (diff)
Various fixes (#3028)
* several thread palette extension fixes * fix svg tartan when original shape is invalid * tartan stroke spaces * style * fix tartan color substituion at pattern start * ripple: do not render too small paths * use less space for params warning headline * fix clone shape path * zip export template fix (typo) * add realistic stitch plan output warning (help tab)
Diffstat (limited to 'lib/extensions/palette_to_text.py')
-rw-r--r--lib/extensions/palette_to_text.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/extensions/palette_to_text.py b/lib/extensions/palette_to_text.py
index db0c50cf..729c92fc 100644
--- a/lib/extensions/palette_to_text.py
+++ b/lib/extensions/palette_to_text.py
@@ -8,6 +8,7 @@ import os
import inkex
from ..i18n import _
+from ..svg.tags import INKSCAPE_GROUPMODE, INKSCAPE_LABEL
from ..threads.palette import ThreadPalette
from .base import InkstitchExtension
@@ -31,11 +32,15 @@ class PaletteToText(InkstitchExtension):
inkex.errormsg(_("Cannot read palette: invalid GIMP palette header"))
return
- current_layer = self.svg.get_current_layer()
+ layer = inkex.Group(attrib={
+ 'id': '__inkstitch_palette__',
+ INKSCAPE_LABEL: _('Thread Palette') + f': {thread_palette.name}',
+ INKSCAPE_GROUPMODE: 'layer',
+ })
+ self.svg.append(layer)
x = 0
y = 0
- pos = 0
for color in thread_palette:
line = "%s %s" % (color.name, color.number)
element = inkex.TextElement()
@@ -43,10 +48,9 @@ class PaletteToText(InkstitchExtension):
element.style = "fill:%s;font-size:4px;" % color.to_hex_str()
element.set('x', x)
element.set('y', str(y))
- current_layer.insert(pos, element)
+ layer.append(element)
y = float(y) + 5
- pos += 1
if __name__ == '__main__':