From 350c292f8d0415fefefa83ce5ce84c2b5c17bd75 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 12 Jun 2018 20:18:55 -0400 Subject: show 'no embroiderable paths' error in Params too --- lib/extensions/base.py | 2 +- lib/extensions/params.py | 29 ++++++++++++++++++++--------- messages.po | 4 ++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/extensions/base.py b/lib/extensions/base.py index 8edfe797..4589132f 100644 --- a/lib/extensions/base.py +++ b/lib/extensions/base.py @@ -111,7 +111,7 @@ class InkstitchExtension(inkex.Effect): inkex.errormsg(_("No embroiderable paths selected.")) else: inkex.errormsg(_("No embroiderable paths found in document.")) - inkex.errormsg(_("Tip: use Path -> Object to Path to convert non-paths before embroidering.")) + inkex.errormsg(_("Tip: use Path -> Object to Path to convert non-paths.")) def descendants(self, node): nodes = [] diff --git a/lib/extensions/params.py b/lib/extensions/params.py index 2e7d3f90..9d8de41b 100644 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -639,6 +639,9 @@ class SettingsFrame(wx.Frame): self.Layout() # end wxGlade +class NoValidObjects(Exception): + pass + class Params(InkstitchExtension): def __init__(self, *args, **kwargs): self.cancelled = False @@ -696,6 +699,11 @@ class Params(InkstitchExtension): def create_tabs(self, parent): tabs = [] + nodes_by_class = self.get_nodes_by_class() + + if not nodes_by_class: + raise NoValidObjects() + for cls, nodes in self.get_nodes_by_class(): params = cls.get_params() @@ -752,12 +760,15 @@ class Params(InkstitchExtension): self.cancelled = True def effect(self): - app = wx.App() - frame = SettingsFrame(tabs_factory=self.create_tabs, on_cancel=self.cancel) - frame.Show() - app.MainLoop() - - if self.cancelled: - # This prevents the superclass from outputting the SVG, because we - # may have modified the DOM. - sys.exit(0) + try: + app = wx.App() + frame = SettingsFrame(tabs_factory=self.create_tabs, on_cancel=self.cancel) + frame.Show() + app.MainLoop() + + if self.cancelled: + # This prevents the superclass from outputting the SVG, because we + # may have modified the DOM. + sys.exit(0) + except NoValidObjects: + self.no_elements_error() diff --git a/messages.po b/messages.po index 02d4aba6..b872f864 100644 --- a/messages.po +++ b/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-06-10 16:01-0400\n" +"POT-Creation-Date: 2018-06-12 20:18-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -185,7 +185,7 @@ msgstr "" msgid "No embroiderable paths found in document." msgstr "" -msgid "Tip: use Path -> Object to Path to convert non-paths before embroidering." +msgid "Tip: use Path -> Object to Path to convert non-paths." msgstr "" msgid "" -- cgit v1.2.3