summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2025-06-29 06:33:06 +0200
committerGitHub <noreply@github.com>2025-06-29 06:33:06 +0200
commit0d461e3aef42b046b7ca14e2b0a05990306030d4 (patch)
tree8adc60944c2c6ecea16774b4b822d812e3f3c33e /lib
parentdd3ae3e8f3bfacb9738a1a7e7df8da6300ebb5a6 (diff)
Fix simulator drawing panel attribute error when no stitch is loaded (#3815)
Diffstat (limited to 'lib')
-rw-r--r--lib/gui/simulator/drawing_panel.py11
-rw-r--r--lib/gui/simulator/simulator_panel.py1
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/gui/simulator/drawing_panel.py b/lib/gui/simulator/drawing_panel.py
index abe6fa0f..d6546c47 100644
--- a/lib/gui/simulator/drawing_panel.py
+++ b/lib/gui/simulator/drawing_panel.py
@@ -66,6 +66,11 @@ class DrawingPanel(wx.Panel):
self.show_page = global_settings['toggle_page_button_status']
self.background_color = None
+ # Set initial values as they may be accessed before a stitch plan is available
+ # for example through a focus action on the stitch box
+ self.num_stitches = 1
+ self.commands = [None]
+
# desired simulation speed in stitches per second
self.speed = global_settings['simulator_speed']
@@ -435,7 +440,11 @@ class DrawingPanel(wx.Panel):
def set_current_stitch(self, stitch):
self.current_stitch = stitch
self.clamp_current_stitch()
- command = self.commands[int(self.current_stitch)]
+ try:
+ command = self.commands[int(self.current_stitch)]
+ except IndexError:
+ # no stitch plan loaded yet, do nothing for now
+ return
self.control_panel.on_current_stitch(int(self.current_stitch), command)
statusbar = self.GetTopLevelParent().statusbar
statusbar.SetStatusText(_("Command: %s") % COMMAND_NAMES[command], 2)
diff --git a/lib/gui/simulator/simulator_panel.py b/lib/gui/simulator/simulator_panel.py
index 1cea9214..efbb2a62 100644
--- a/lib/gui/simulator/simulator_panel.py
+++ b/lib/gui/simulator/simulator_panel.py
@@ -58,7 +58,6 @@ class SimulatorPanel(wx.Panel):
(wx.ACCEL_SHIFT, ord('='), self.cp.animation_one_stitch_forward),
(wx.ACCEL_NORMAL, wx.WXK_ADD, self.cp.animation_one_stitch_forward),
(wx.ACCEL_NORMAL, wx.WXK_NUMPAD_ADD, self.cp.animation_one_stitch_forward),
- (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_UP, self.cp.animation_one_stitch_forward),
(wx.ACCEL_NORMAL, ord('-'), self.cp.animation_one_stitch_backward),
(wx.ACCEL_NORMAL, ord('_'), self.cp.animation_one_stitch_backward),
(wx.ACCEL_NORMAL, wx.WXK_SUBTRACT, self.cp.animation_one_stitch_backward),