summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-05-02 06:50:52 +0200
committerGitHub <noreply@github.com>2024-05-02 06:50:52 +0200
commit04e74c2c8ff727256cd9c4b7bef014a96fb70849 (patch)
treea5dac48fd672d0f35325712a3cb5e0b6de9f7449
parent5eb243e9ebe5d1061fde9f19d5d2ac9b7ad7ec37 (diff)
cancel simulator extensions without applying changes (#2876)
-rw-r--r--lib/extensions/params.py12
-rw-r--r--lib/gui/lettering.py12
-rw-r--r--lib/gui/satin_multicolor/main_panel.py11
-rw-r--r--lib/gui/simulator.py11
-rw-r--r--lib/gui/tartan/main_panel.py11
5 files changed, 29 insertions, 28 deletions
diff --git a/lib/extensions/params.py b/lib/extensions/params.py
index 0a593fdc..076ed301 100644
--- a/lib/extensions/params.py
+++ b/lib/extensions/params.py
@@ -474,9 +474,8 @@ class ParamsTab(ScrolledPanel):
class SettingsPanel(wx.Panel):
- def __init__(self, parent, tabs_factory=None, on_cancel=None, metadata=None, background_color='white', simulator=None):
+ def __init__(self, parent, tabs_factory=None, metadata=None, background_color='white', simulator=None):
self.tabs_factory = tabs_factory
- self.cancel_hook = on_cancel
self.metadata = metadata
self.background_color = background_color
self.simulator = simulator
@@ -610,13 +609,12 @@ class SettingsPanel(wx.Panel):
self.apply(event)
def close(self):
- wx.CallAfter(self.GetTopLevelParent().Close)
+ self.simulator.stop()
+ wx.CallAfter(self.GetTopLevelParent().close)
def cancel(self, event):
- if self.cancel_hook:
- self.cancel_hook()
-
- self.close()
+ self.simulator.stop()
+ wx.CallAfter(self.GetTopLevelParent().cancel)
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
diff --git a/lib/gui/lettering.py b/lib/gui/lettering.py
index 57d8a85d..bce39ff8 100644
--- a/lib/gui/lettering.py
+++ b/lib/gui/lettering.py
@@ -25,11 +25,10 @@ from . import PresetsPanel, PreviewRenderer, info_dialog
class LetteringPanel(wx.Panel):
DEFAULT_FONT = "small_font"
- def __init__(self, parent, simulator, group, on_cancel=None, metadata=None, background_color='white'):
+ def __init__(self, parent, simulator, group, metadata=None, background_color='white'):
self.parent = parent
self.simulator = simulator
self.group = group
- self.cancel_hook = on_cancel
self.metadata = metadata or dict()
self.background_color = background_color
@@ -397,13 +396,12 @@ class LetteringPanel(wx.Panel):
self.close()
def close(self):
- self.GetTopLevelParent().Close()
+ self.simulator.stop()
+ wx.CallAfter(self.GetTopLevelParent().close)
def cancel(self, event):
- if self.cancel_hook:
- self.cancel_hook()
-
- self.close()
+ self.simulator.stop()
+ wx.CallAfter(self.GetTopLevelParent().cancel)
def __do_layout(self):
outer_sizer = wx.BoxSizer(wx.VERTICAL)
diff --git a/lib/gui/satin_multicolor/main_panel.py b/lib/gui/satin_multicolor/main_panel.py
index fb16413e..0ceebb4f 100644
--- a/lib/gui/satin_multicolor/main_panel.py
+++ b/lib/gui/satin_multicolor/main_panel.py
@@ -21,11 +21,10 @@ from .help_panel import HelpPanel
class MultiColorSatinPanel(wx.Panel):
- def __init__(self, parent, simulator, elements, on_cancel=None, metadata=None, background_color='white'):
+ def __init__(self, parent, simulator, elements, metadata=None, background_color='white'):
self.parent = parent
self.simulator = simulator
self.elements = elements
- self.cancel_hook = on_cancel
self.metadata = metadata or dict()
self.background_color = background_color
self.output_groups = []
@@ -83,12 +82,12 @@ class MultiColorSatinPanel(wx.Panel):
self.preview_renderer.update()
def close(self):
- self.GetTopLevelParent().Close()
+ self.simulator.stop()
+ wx.CallAfter(self.GetTopLevelParent().close)
def cancel(self, event):
- if self.cancel_hook:
- self.cancel_hook()
- self.close()
+ self.simulator.stop()
+ wx.CallAfter(self.GetTopLevelParent().cancel)
def apply(self, event):
self.update_satin_elements()
diff --git a/lib/gui/simulator.py b/lib/gui/simulator.py
index 79f3d95d..a8e917b4 100644
--- a/lib/gui/simulator.py
+++ b/lib/gui/simulator.py
@@ -1159,6 +1159,7 @@ class SplitSimulatorWindow(wx.Frame):
self.detached_simulator_frame = None
self.splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE)
background_color = kwargs.pop('background_color', 'white')
+ self.cancel_hook = kwargs.pop('on_cancel', None)
self.simulator_panel = SimulatorPanel(
self.splitter,
background_color=background_color,
@@ -1187,7 +1188,7 @@ class SplitSimulatorWindow(wx.Frame):
wx.CallLater(100, self.set_sash_position)
self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, self.splitter_resize)
- self.Bind(wx.EVT_CLOSE, self.on_close)
+ self.Bind(wx.EVT_CLOSE, self.cancel)
if global_settings['pop_out_simulator']:
self.detach_simulator()
@@ -1201,7 +1202,13 @@ class SplitSimulatorWindow(wx.Frame):
self.splitter.SetSashPosition(settings_panel_min_size.width)
self.statusbar.SetStatusWidths((settings_panel_min_size.width, -1))
- def on_close(self, event):
+ def cancel(self, event=None):
+ if self.cancel_hook:
+ self.cancel_hook()
+ self.close(None)
+
+ def close(self, event=None):
+ self.simulator_panel.stop()
if self.detached_simulator_frame:
self.detached_simulator_frame.Destroy()
self.Destroy()
diff --git a/lib/gui/tartan/main_panel.py b/lib/gui/tartan/main_panel.py
index 74087426..34015fb4 100644
--- a/lib/gui/tartan/main_panel.py
+++ b/lib/gui/tartan/main_panel.py
@@ -25,11 +25,10 @@ from . import CodePanel, CustomizePanel, EmbroideryPanel, HelpPanel
class TartanMainPanel(wx.Panel):
- def __init__(self, parent, simulator, elements, on_cancel=None, metadata=None, background_color='white'):
+ def __init__(self, parent, simulator, elements, metadata=None, background_color='white'):
self.parent = parent
self.simulator = simulator
self.elements = elements
- self.cancel_hook = on_cancel
self.palette = Palette()
self.metadata = metadata or dict()
self.background_color = background_color
@@ -195,12 +194,12 @@ class TartanMainPanel(wx.Panel):
return "tartan"
def close(self):
- self.GetTopLevelParent().Close()
+ self.simulator.stop()
+ wx.CallAfter(self.GetTopLevelParent().close)
def cancel(self, event):
- if self.cancel_hook:
- self.cancel_hook()
- self.close()
+ self.simulator.stop()
+ wx.CallAfter(self.GetTopLevelParent().cancel)
def apply(self, event):
self.update_tartan()