summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMomo <reni@allenka.de>2018-08-20 18:28:52 +0200
committerMomo <reni@allenka.de>2018-08-20 18:28:52 +0200
commita1440903cb91f3effd7cd23a395dbe3f8f9bed00 (patch)
tree0233bcdf8b4dc19dbb5cf82b95f3301e8653f0fc
parentbcd16c78b4ba772bfc6187b2452390a7a37d3329 (diff)
update slider maxValue when params have changed
-rw-r--r--lib/extensions/params.py7
-rw-r--r--lib/simulator.py12
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/extensions/params.py b/lib/extensions/params.py
index c464e044..ce06cf2c 100644
--- a/lib/extensions/params.py
+++ b/lib/extensions/params.py
@@ -287,7 +287,6 @@ class ParamsTab(ScrolledPanel):
summary_box = wx.StaticBox(self, wx.ID_ANY, label=_("Inkscape objects"))
sizer = wx.StaticBoxSizer(summary_box, wx.HORIZONTAL)
-# sizer = wx.BoxSizer(wx.HORIZONTAL)
self.description = wx.StaticText(self)
self.update_description()
self.description.SetLabel(self.description_text)
@@ -423,6 +422,12 @@ class SettingsFrame(wx.Frame):
if self.simulate_window:
self.simulate_window.stop()
self.simulate_window.load(stitch_plan=stitch_plan)
+
+ children = self.simulate_window.GetChildren()
+ for child in children:
+ if isinstance(child, wx.Slider):
+ child.Destroy()
+ self.simulate_window.set_slider()
else:
params_rect = self.GetScreenRect()
simulator_pos = params_rect.GetTopRight()
diff --git a/lib/simulator.py b/lib/simulator.py
index f937e614..67a261c6 100644
--- a/lib/simulator.py
+++ b/lib/simulator.py
@@ -37,11 +37,8 @@ class EmbroiderySimulator(wx.Frame):
self.panel = wx.Panel(self, wx.ID_ANY)
self.panel.SetBackgroundStyle(wx.BG_STYLE_PAINT)
- self.stitch_slider = wx.Slider(self, value=1, minValue=1, maxValue=len(self.lines),
- style = wx.SL_HORIZONTAL|wx.SL_LABELS)
-
self.slider_sizer = wx.BoxSizer(wx.HORIZONTAL)
- self.slider_sizer.Add(self.stitch_slider, 1, wx.EXPAND)
+ self.set_slider()
self.button_sizer = wx.StdDialogButtonSizer()
self.button_label = (
@@ -123,6 +120,11 @@ class EmbroiderySimulator(wx.Frame):
self.last_pos = None
+ def set_slider(self):
+ self.stitch_slider = wx.Slider(self, value=1, minValue=1, maxValue=len(self.lines),
+ style = wx.SL_HORIZONTAL|wx.SL_LABELS)
+ self.slider_sizer.Add(self.stitch_slider, 1, wx.EXPAND)
+
def get_current_screen_rect(self):
current_screen = wx.Display.GetFromPoint(wx.GetMousePosition())
display = wx.Display(current_screen)
@@ -361,7 +363,7 @@ class EmbroiderySimulator(wx.Frame):
dc.DrawLine(self.last_pos_x, self.last_pos_y - 10, self.last_pos_x, self.last_pos_y + 10)
def iterate_frames(self):
- self.current_frame += 1 * self.animation_direction
+ self.current_frame += self.stitches_per_frame * self.animation_direction
self.set_stitch_counter(self.current_frame)
self.set_stitch_slider(self.current_frame)