summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/extensions/install.py4
-rw-r--r--lib/extensions/params.py8
-rw-r--r--lib/i18n.py2
-rw-r--r--lib/inx/utils.py2
-rw-r--r--lib/simulator.py54
5 files changed, 46 insertions, 24 deletions
diff --git a/lib/extensions/install.py b/lib/extensions/install.py
index c6dadd42..f9ffe958 100644
--- a/lib/extensions/install.py
+++ b/lib/extensions/install.py
@@ -24,8 +24,8 @@ class InstallerFrame(wx.Frame):
text = (_('Ink/Stitch can install files ("add-ons") that make it easier to use Inkscape to create machine embroidery designs. '
'These add-ons will be installed:') +
- "\n\n • " + _("thread manufacturer color palettes") +
- "\n • " + _("Ink/Stitch visual commands (Object -> Symbols...)"))
+ u"\n\n • " + _("thread manufacturer color palettes") +
+ u"\n • " + _("Ink/Stitch visual commands (Object -> Symbols...)"))
static_text = wx.StaticText(panel, label=text)
font = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
diff --git a/lib/extensions/params.py b/lib/extensions/params.py
index 664486cd..1f3032ca 100644
--- a/lib/extensions/params.py
+++ b/lib/extensions/params.py
@@ -250,16 +250,16 @@ class ParamsTab(ScrolledPanel):
description = _("These settings will be applied to %d objects.") % len(self.nodes)
if any(len(param.values) > 1 for param in self.params):
- description += "\n • " + _("Some settings had different values across objects. Select a value from the dropdown or enter a new one.")
+ description += u"\n • " + _("Some settings had different values across objects. Select a value from the dropdown or enter a new one.")
if self.dependent_tabs:
if len(self.dependent_tabs) == 1:
- description += "\n • " + _("Disabling this tab will disable the following %d tabs.") % len(self.dependent_tabs)
+ description += u"\n • " + _("Disabling this tab will disable the following %d tabs.") % len(self.dependent_tabs)
else:
- description += "\n • " + _("Disabling this tab will disable the following tab.")
+ description += u"\n • " + _("Disabling this tab will disable the following tab.")
if self.paired_tab:
- description += "\n • " + _("Enabling this tab will disable %s and vice-versa.") % self.paired_tab.name
+ description += u"\n • " + _("Enabling this tab will disable %s and vice-versa.") % self.paired_tab.name
self.description_text = description
diff --git a/lib/i18n.py b/lib/i18n.py
index 045fa1b2..98f63ec1 100644
--- a/lib/i18n.py
+++ b/lib/i18n.py
@@ -30,7 +30,7 @@ def localize(languages=None):
global translation, _
translation = gettext.translation("inkstitch", locale_dir, fallback=True)
- _ = translation.gettext
+ _ = translation.ugettext
_set_locale_dir()
diff --git a/lib/inx/utils.py b/lib/inx/utils.py
index 54b37c58..a22b1892 100644
--- a/lib/inx/utils.py
+++ b/lib/inx/utils.py
@@ -44,7 +44,7 @@ def iterate_inx_locales():
# generate menu items for this language in Inkscape's "Extensions"
# menu.
magic_string = N_("Generate INX files")
- translated_magic_string = translation.gettext(magic_string)
+ translated_magic_string = translation.ugettext(magic_string)
if translated_magic_string != magic_string or locale == "en_US":
current_translation = translation
diff --git a/lib/simulator.py b/lib/simulator.py
index 5855264d..34d12887 100644
--- a/lib/simulator.py
+++ b/lib/simulator.py
@@ -30,6 +30,8 @@ class ControlPanel(wx.Panel):
kwargs['style'] = wx.BORDER_SUNKEN
wx.Panel.__init__(self, parent, *args, **kwargs)
+ self.statusbar = self.GetTopLevelParent().statusbar
+
self.drawing_panel = None
self.num_stitches = 1
self.current_stitch = 1
@@ -39,27 +41,33 @@ class ControlPanel(wx.Panel):
# Widgets
self.btnMinus = wx.Button(self, -1, label='-')
self.btnMinus.Bind(wx.EVT_BUTTON, self.animation_slow_down)
+ self.btnMinus.SetToolTip(_('Slow down (arrow down)'))
self.btnPlus = wx.Button(self, -1, label='+')
self.btnPlus.Bind(wx.EVT_BUTTON, self.animation_speed_up)
+ self.btnPlus.SetToolTip(_('Speed up (arrow up)'))
self.btnBackwardStitch = wx.Button(self, -1, label='<|')
self.btnBackwardStitch.Bind(wx.EVT_BUTTON, self.animation_one_stitch_backward)
+ self.btnBackwardStitch.SetToolTip(_('Go on step backward (-)'))
self.btnForwardStitch = wx.Button(self, -1, label='|>')
self.btnForwardStitch.Bind(wx.EVT_BUTTON, self.animation_one_stitch_forward)
+ self.btnForwardStitch.SetToolTip(_('Go on step forward (+)'))
self.directionBtn = wx.Button(self, -1, label='<<')
self.directionBtn.Bind(wx.EVT_BUTTON, self.on_direction_button)
+ self.directionBtn.SetToolTip(_('Switch direction (arrow left | arrow right)'))
self.pauseBtn = wx.Button(self, -1, label=_('Pause'))
self.pauseBtn.Bind(wx.EVT_BUTTON, self.on_pause_start_button)
+ self.pauseBtn.SetToolTip(_('Pause (P)'))
self.restartBtn = wx.Button(self, -1, label=_('Restart'))
self.restartBtn.Bind(wx.EVT_BUTTON, self.animation_restart)
+ self.restartBtn.SetToolTip(_('Restart (R)'))
self.quitBtn = wx.Button(self, -1, label=_('Quit'))
self.quitBtn.Bind(wx.EVT_BUTTON, self.animation_quit)
+ self.quitBtn.SetToolTip(_('Quit (Q)'))
self.slider = wx.Slider(self, -1, value=1, minValue=1, maxValue=2,
style=wx.SL_HORIZONTAL | wx.SL_LABELS)
self.slider.Bind(wx.EVT_SLIDER, self.on_slider)
self.stitchBox = IntCtrl(self, -1, value=1, min=1, max=2, limited=True, allow_none=False)
self.stitchBox.Bind(wx.EVT_TEXT, self.on_stitch_box)
- self.speedST = wx.StaticText(self, -1, label='', style=wx.ALIGN_CENTER)
- self.commandST = wx.StaticText(self, -1, label='', style=wx.ALIGN_CENTER)
# Layout
self.vbSizer = vbSizer = wx.BoxSizer(wx.VERTICAL)
@@ -68,20 +76,16 @@ class ControlPanel(wx.Panel):
hbSizer1.Add(self.slider, 1, wx.EXPAND | wx.ALL, 3)
hbSizer1.Add(self.stitchBox, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2)
vbSizer.Add(hbSizer1, 1, wx.EXPAND | wx.ALL, 3)
- hbSizer2.Add(self.speedST, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2)
- hbSizer2.AddStretchSpacer(prop=1)
- hbSizer2.Add(self.commandST, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2)
- hbSizer2.AddStretchSpacer(prop=1)
- hbSizer2.Add(self.btnMinus, 0, wx.ALL, 2)
- hbSizer2.Add(self.btnPlus, 0, wx.ALL, 2)
- hbSizer2.Add(self.btnBackwardStitch, 0, wx.ALL, 2)
- hbSizer2.Add(self.btnForwardStitch, 0, wx.ALL, 2)
+ hbSizer2.Add(self.btnMinus, 0, wx.EXPAND | wx.ALL, 2)
+ hbSizer2.Add(self.btnPlus, 0, wx.EXPAND | wx.ALL, 2)
+ hbSizer2.Add(self.btnBackwardStitch, 0, wx.EXPAND | wx.ALL, 2)
+ hbSizer2.Add(self.btnForwardStitch, 0, wx.EXPAND | wx.ALL, 2)
hbSizer2.Add(self.directionBtn, 0, wx.EXPAND | wx.ALL, 2)
hbSizer2.Add(self.pauseBtn, 0, wx.EXPAND | wx.ALL, 2)
hbSizer2.Add(self.restartBtn, 0, wx.EXPAND | wx.ALL, 2)
hbSizer2.Add(self.quitBtn, 0, wx.EXPAND | wx.ALL, 2)
vbSizer.Add(hbSizer2, 0, wx.EXPAND | wx.ALL, 3)
- self.SetSizer(vbSizer)
+ self.SetSizerAndFit(vbSizer)
# Keyboard Shortcuts
shortcut_keys = [
@@ -152,9 +156,9 @@ class ControlPanel(wx.Panel):
def on_direction_button(self, event):
if self.direction == 1:
- self.animation_forward()
- else:
self.animation_reverse()
+ else:
+ self.animation_forward()
def set_speed(self, speed):
self.speed = int(max(speed, 1))
@@ -164,7 +168,7 @@ class ControlPanel(wx.Panel):
self.drawing_panel.set_speed(self.speed)
def update_speed_text(self):
- self.speedST.SetLabel(_('Speed: %d stitches/sec') % (self.speed * self.direction))
+ self.statusbar.SetStatusText(_('Speed: %d stitches/sec') % (self.speed * self.direction), 0)
self.hbSizer2.Layout()
def on_slider(self, event):
@@ -179,7 +183,7 @@ class ControlPanel(wx.Panel):
self.current_stitch = stitch
self.slider.SetValue(stitch)
self.stitchBox.SetValue(stitch)
- self.commandST.SetLabel(COMMAND_NAMES[command])
+ self.statusbar.SetStatusText(COMMAND_NAMES[command], 1)
def on_stitch_box(self, event):
stitch = self.stitchBox.GetValue()
@@ -216,9 +220,11 @@ class ControlPanel(wx.Panel):
self.animation_start()
def animation_one_stitch_forward(self, event):
+ self.animation_pause()
self.drawing_panel.one_stitch_forward()
def animation_one_stitch_backward(self, event):
+ self.animation_pause()
self.drawing_panel.one_stitch_backward()
def animation_quit(self, event):
@@ -250,6 +256,9 @@ class DrawingPanel(wx.Panel):
kwargs['style'] = wx.BORDER_SUNKEN
wx.Panel.__init__(self, *args, **kwargs)
+ # Drawing panel can really be any size, but without this wxpython likes
+ # to allow the status bar and control panel to get squished.
+ self.SetMinSize((100, 100))
self.SetBackgroundColour('#FFFFFF')
self.SetDoubleBuffered(True)
@@ -558,7 +567,7 @@ class SimulatorPanel(wx.Panel):
vbSizer = wx.BoxSizer(wx.VERTICAL)
vbSizer.Add(self.dp, 1, wx.EXPAND | wx.ALL, 2)
vbSizer.Add(self.cp, 0, wx.EXPAND | wx.ALL, 2)
- self.SetSizer(vbSizer)
+ self.SetSizerAndFit(vbSizer)
def quit(self):
self.parent.quit()
@@ -582,12 +591,25 @@ class EmbroiderySimulator(wx.Frame):
stitch_plan = kwargs.pop('stitch_plan', None)
stitches_per_second = kwargs.pop('stitches_per_second', 16)
target_duration = kwargs.pop('target_duration', None)
+ size = kwargs.get('size', (0, 0))
wx.Frame.__init__(self, *args, **kwargs)
+ self.statusbar = self.CreateStatusBar(2)
+ self.statusbar.SetStatusWidths([250, -1])
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
self.simulator_panel = SimulatorPanel(self,
stitch_plan=stitch_plan,
target_duration=target_duration,
stitches_per_second=stitches_per_second)
+ sizer.Add(self.simulator_panel, 1, wx.EXPAND)
+
+ # self.SetSizerAndFit() sets the minimum size so that the buttons don't
+ # get squished. But it then also shrinks the window down to that size.
+ self.SetSizerAndFit(sizer)
+
+ # Therefore we have to reapply the size that the caller asked for.
+ self.SetSize(size)
+
self.Bind(wx.EVT_CLOSE, self.on_close)
def quit(self):