diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-11-18 11:12:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-18 11:12:58 +0100 |
| commit | e8123b72744b81302f1d264082940b58b3695584 (patch) | |
| tree | 786c9ab5b5bc35f9023f7ce40634bb38f1e3298b /lib/extensions/apply_palette.py | |
| parent | b20ad42733ae54ffb260c0262c5689c87515eae3 (diff) | |
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
Diffstat (limited to 'lib/extensions/apply_palette.py')
| -rw-r--r-- | lib/extensions/apply_palette.py | 18 |
1 files changed, 13 insertions, 5 deletions
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 |
