diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2021-04-10 19:55:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-10 19:55:48 +0200 |
| commit | 7ce3c8e7a04b86163f3b9f0a206b135411e3293b (patch) | |
| tree | fb9ead1ac9c2d00bede6945b28c44a23d7bed3bc /lib/gui | |
| parent | 22f1bc5cb007fe44ed5b238d197e5ce83180d33b (diff) | |
output a warning in params if simulation cannot load (#1143)
Diffstat (limited to 'lib/gui')
| -rw-r--r-- | lib/gui/__init__.py | 1 | ||||
| -rw-r--r-- | lib/gui/dialogs.py | 2 | ||||
| -rw-r--r-- | lib/gui/simulator.py | 6 | ||||
| -rw-r--r-- | lib/gui/warnings.py | 28 |
4 files changed, 30 insertions, 7 deletions
diff --git a/lib/gui/__init__.py b/lib/gui/__init__.py index 1509fa77..aac2319f 100644 --- a/lib/gui/__init__.py +++ b/lib/gui/__init__.py @@ -7,3 +7,4 @@ from .dialogs import confirm_dialog, info_dialog from .electron import open_url from .presets import PresetsPanel from .simulator import EmbroiderySimulator, SimulatorPreview, show_simulator +from .warnings import WarningPanel diff --git a/lib/gui/dialogs.py b/lib/gui/dialogs.py index e270d2e5..326f8c72 100644 --- a/lib/gui/dialogs.py +++ b/lib/gui/dialogs.py @@ -13,7 +13,7 @@ def confirm_dialog(parent, question, caption='ink/stitch'): return result -def info_dialog(parent, message, caption='ink/stitch'): +def info_dialog(parent, message, caption='Ink/Stitch'): dlg = wx.MessageDialog(parent, message, caption, wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() diff --git a/lib/gui/simulator.py b/lib/gui/simulator.py index 27b9a97e..3e1f68c5 100644 --- a/lib/gui/simulator.py +++ b/lib/gui/simulator.py @@ -5,13 +5,11 @@ import sys import time -import traceback from threading import Event, Thread import wx from wx.lib.intctrl import IntCtrl -from .dialogs import info_dialog from ..i18n import _ from ..stitch_plan import patches_to_stitch_plan, stitch_plan_from_file from ..svg import PIXELS_PER_MM @@ -822,8 +820,6 @@ class SimulatorPreview(Thread): on_close=self.simulate_window_closed, target_duration=self.target_duration) except Exception: - error = traceback.format_exc() - try: # a window may have been created, so we need to destroy it # or the app will never exit @@ -831,8 +827,6 @@ class SimulatorPreview(Thread): except Exception: pass - info_dialog(self, error, _("Internal Error")) - self.simulate_window.Show() wx.CallLater(10, self.parent.Raise) diff --git a/lib/gui/warnings.py b/lib/gui/warnings.py new file mode 100644 index 00000000..48788652 --- /dev/null +++ b/lib/gui/warnings.py @@ -0,0 +1,28 @@ +# Authors: see git history +# +# Copyright (c) 2021 Authors +# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. + +import wx + +from ..i18n import _ + + +class WarningPanel(wx.Panel): + """A wx.Panel for to display warnings. + """ + + def __init__(self, parent, *args, **kwargs): + wx.Panel.__init__(self, parent, wx.ID_ANY, *args, **kwargs) + + self.warning_box = wx.StaticBox(self, wx.ID_ANY) + + self.warning = wx.StaticText(self) + self.warning.SetLabel(_("Cannot load simulator.\nClose Params to get full error message.")) + self.warning.SetForegroundColour(wx.Colour(255, 25, 25)) + + warning_sizer = wx.StaticBoxSizer(self.warning_box, wx.HORIZONTAL) + warning_sizer.Add(self.warning, 1, wx.LEFT | wx.BOTTOM | wx.EXPAND, 10) + + self.SetSizerAndFit(warning_sizer) + self.Layout() |
