From 2235ec6571601e12be7eb3c74907668fb68bebd4 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Fri, 11 Jul 2025 22:14:52 +0200 Subject: Fix issue with bad color names (#3816) * fix issue with bad color names and define element colors at one place and reuse * fix bad tartan color * verify color in gradient block * add thread color tests * use default color behavior for elements linked to non-existing definitions (gradients) * Added mypy change for tests (authored by: CapellanCitizen) --- lib/tartan/palette.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/tartan/palette.py') diff --git a/lib/tartan/palette.py b/lib/tartan/palette.py index 25bd2100..b8c36331 100644 --- a/lib/tartan/palette.py +++ b/lib/tartan/palette.py @@ -8,9 +8,10 @@ import re from typing import TYPE_CHECKING, List, cast import wx -from inkex import Color +from inkex import Color, ColorError from .colors import string_to_color + if TYPE_CHECKING: from ..gui.tartan.stripe_panel import StripePanel @@ -175,7 +176,11 @@ class Palette: color = wx.Colour(color).GetAsString(wx.C2S_HTML_SYNTAX) except wx.PyNoAppError: # however when we render an embroidery element we do not want to open wx.App - color = str(Color(color).to_named()) + try: + color = str(Color(color).to_named()) + except ColorError: + color = None + if not color: color = '#000000' render = 0 -- cgit v1.2.3