From e8123b72744b81302f1d264082940b58b3695584 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:12:58 +0100 Subject: Thread catalog: fix broken path (#3281) * thread catalog: fix broken path * apply threadlist: use wxpython to also include custom lists * apply_palette: save last choice --- lib/extensions/apply_palette.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/extensions/apply_palette.py') diff --git a/lib/extensions/apply_palette.py b/lib/extensions/apply_palette.py index cd8c4c94..373824b6 100644 --- a/lib/extensions/apply_palette.py +++ b/lib/extensions/apply_palette.py @@ -4,6 +4,9 @@ # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. from ..elements import Clone, FillStitch +from ..gui.abort_message import AbortMessageApp +from ..gui.apply_palette import ApplyPaletteApp +from ..i18n import _ from ..threads import ThreadCatalog, ThreadColor from .base import InkstitchExtension @@ -12,19 +15,24 @@ class ApplyPalette(InkstitchExtension): ''' Applies colors of a color palette to elements ''' - def __init__(self, *args, **kwargs): - InkstitchExtension.__init__(self, *args, **kwargs) - self.arg_parser.add_argument("-o", "--tabs") - self.arg_parser.add_argument("-t", "--palette", type=str, default=None, dest="palette") def effect(self): # Remove selection, we want all the elements in the document self.svg.selection.clear() if not self.get_elements(): + app = AbortMessageApp( + _("There is no stitchable element in the document."), + _("https://inkstitch.org/") + ) + app.MainLoop() return - palette_name = self.options.palette + palette_choice = ApplyPaletteApp() + if palette_choice.palette: + self.apply_palette(palette_choice.palette) + + def apply_palette(self, palette_name): palette = ThreadCatalog().get_palette_by_name(palette_name) # Iterate through the color blocks to apply colors -- cgit v1.2.3