From 5c0e2b8e9fcba9f06b288e6dbf8d5183fb93d5d4 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 24 Aug 2018 21:25:30 -0400 Subject: don't show an icon on windows --- lib/extensions/install.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/install.py b/lib/extensions/install.py index 6c179beb..d8e91a8d 100644 --- a/lib/extensions/install.py +++ b/lib/extensions/install.py @@ -56,6 +56,13 @@ class InstallerFrame(wx.Frame): self.path_input.SetValue(dialog.GetPath()) def install_button_clicked(self, event): + if sys.platform == "win32": + # On windows, the default icon shows as a broken image. No idea + # why. Workaround: don't show an icon. + style = wx.ICON_NONE + else: + style = 0 + try: self.install_addons('palettes') self.install_addons('symbols') @@ -63,12 +70,12 @@ class InstallerFrame(wx.Frame): wx.MessageDialog(self, _('Inkscape add-on installation failed') + ': \n' + traceback.format_exc(), _('Installation Failed'), - wx.OK).ShowModal() + wx.OK | style).ShowModal() else: wx.MessageDialog(self, _('Inkscape add-on files have been installed. Please restart Inkscape to load the new add-ons.'), _('Installation Completed'), - wx.OK).ShowModal() + wx.OK | style).ShowModal() self.Destroy() -- cgit v1.3.1 From 1531e8f52014c871646db770e0066d56d757a880 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 24 Aug 2018 21:47:23 -0400 Subject: support ~, and %vars% in Embroider output directory (#279) --- lib/extensions/embroider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/extensions') diff --git a/lib/extensions/embroider.py b/lib/extensions/embroider.py index 921201d6..7c8adfc9 100644 --- a/lib/extensions/embroider.py +++ b/lib/extensions/embroider.py @@ -39,7 +39,7 @@ class Embroider(InkstitchExtension): def get_output_path(self): if self.options.output_file: - output_path = os.path.join(self.options.path, self.options.output_file) + output_path = os.path.join(os.path.expanduser(os.path.expandvars(self.options.path)), self.options.output_file) else: csv_filename = '%s.%s' % (self.get_base_file_name(), self.options.output_format) output_path = os.path.join(self.options.path, csv_filename) -- cgit v1.3.1 From e2b5e968340aeab55c4b7c280946640fb3131107 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 1 Sep 2018 16:26:47 -0400 Subject: add change indicator to Params (#217) --- Makefile | 6 ++--- icons/pencil.png | Bin 0 -> 15456 bytes icons/pencil_20x20.png | Bin 0 -> 734 bytes lib/extensions/params.py | 47 +++++++++++++++++++++++++++++++------- messages.po | 58 +++++++++++++++++++++++++++-------------------- 5 files changed, 76 insertions(+), 35 deletions(-) create mode 100644 icons/pencil.png create mode 100644 icons/pencil_20x20.png (limited to 'lib/extensions') diff --git a/Makefile b/Makefile index 770fd585..ace17e92 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,9 @@ dist: distclean locales inx cp -a images/examples dist/inkstitch cp -a palettes dist/inkstitch cp -a symbols dist/inkstitch - mkdir -p dist/inkstitch/bin/locales - cp -a locales/* dist/inkstitch/bin/locales - cp -a print dist/inkstitch/bin/ + cp -a icons dist/inkstitch/bin + cp -a locales dist/inkstitch/bin + cp -a print dist/inkstitch/bin if [ "$$BUILD" = "windows" ]; then \ cd dist; zip -r ../inkstitch-$(VERSION)-win32.zip *; \ else \ diff --git a/icons/pencil.png b/icons/pencil.png new file mode 100644 index 00000000..70e1d60e Binary files /dev/null and b/icons/pencil.png differ diff --git a/icons/pencil_20x20.png b/icons/pencil_20x20.png new file mode 100644 index 00000000..cd902ba5 Binary files /dev/null and b/icons/pencil_20x20.png differ diff --git a/lib/extensions/params.py b/lib/extensions/params.py index c464e044..c301ed1a 100644 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -17,7 +17,7 @@ from .base import InkstitchExtension from ..i18n import _ from ..stitch_plan import patches_to_stitch_plan from ..elements import EmbroideryElement, Fill, AutoFill, Stroke, SatinColumn -from ..utils import save_stderr, restore_stderr +from ..utils import save_stderr, restore_stderr, get_bundled_dir from ..simulator import EmbroiderySimulator from ..commands import is_command @@ -112,10 +112,14 @@ class ParamsTab(ScrolledPanel): else: self.toggle = None - self.settings_grid = wx.FlexGridSizer(rows=0, cols=3, hgap=10, vgap=10) - self.settings_grid.AddGrowableCol(0, 1) + self.param_change_indicators = {} + + self.settings_grid = wx.FlexGridSizer(rows=0, cols=4, hgap=10, vgap=15) + self.settings_grid.AddGrowableCol(1, 2) self.settings_grid.SetFlexibleDirection(wx.HORIZONTAL) + self.pencil_icon = wx.Image(os.path.join(get_bundled_dir("icons"), "pencil_20x20.png")).ConvertToBitmap() + self.__set_properties() self.__do_layout() @@ -218,7 +222,11 @@ class ParamsTab(ScrolledPanel): self.on_change_hook = callable def changed(self, event): - self.changed_inputs.add(event.GetEventObject()) + input = event.GetEventObject() + self.changed_inputs.add(input) + + param = self.inputs_to_params[input] + self.enable_change_indicator(param) event.Skip() if self.on_change_hook: @@ -297,13 +305,17 @@ class ParamsTab(ScrolledPanel): box.Add(sizer, proportion=0, flag=wx.ALL, border=5) if self.toggle: - box.Add(self.toggle_checkbox, proportion=0, flag=wx.BOTTOM, border=10) + toggle_sizer = wx.BoxSizer(wx.HORIZONTAL) + toggle_sizer.Add(self.create_change_indicator(self.toggle.name), proportion = 0, flag=wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, border=5) + toggle_sizer.Add(self.toggle_checkbox, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + box.Add(toggle_sizer, proportion=0, flag=wx.BOTTOM, border=10) for param in self.params: + self.settings_grid.Add(self.create_change_indicator(param.name), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + description = wx.StaticText(self, label=param.description) description.SetToolTip(param.tooltip) - - self.settings_grid.Add(description, proportion=1, flag=wx.EXPAND|wx.RIGHT, border=40) + self.settings_grid.Add(description, proportion=1, flag=wx.EXPAND|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.TOP, border=5) if param.type == 'boolean': @@ -327,14 +339,33 @@ class ParamsTab(ScrolledPanel): self.param_inputs[param.name] = input - self.settings_grid.Add(input, proportion=1, flag=wx.ALIGN_CENTER_VERTICAL) + self.settings_grid.Add(input, proportion=1, flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND|wx.LEFT, border=40) self.settings_grid.Add(wx.StaticText(self, label=param.unit or ""), proportion=1, flag=wx.ALIGN_CENTER_VERTICAL) + self.inputs_to_params = {v: k for k, v in self.param_inputs.iteritems()} + box.Add(self.settings_grid, proportion=1, flag=wx.ALL, border=10) self.SetSizer(box) self.Layout() + def create_change_indicator(self, param): + indicator = wx.Button(self, style=wx.BORDER_NONE | wx.BU_NOTEXT, size=(28, 28)) + indicator.SetToolTip(_('Click to force this parameter to be saved when you click "Apply and Quit"')) + indicator.Bind(wx.EVT_BUTTON, lambda event: self.enable_change_indicator(param)) + + self.param_change_indicators[param] = indicator + return indicator + + def enable_change_indicator(self, param): + self.param_change_indicators[param].SetBitmapLabel(self.pencil_icon) + self.param_change_indicators[param].SetToolTip(_('This parameter will be saved when you click "Apply and Quit"')) + + self.changed_inputs.add(self.param_inputs[param]) + + if self.on_change_hook(): + self.on_change_hook(self) + # end of class SatinPane class SettingsFrame(wx.Frame): diff --git a/messages.po b/messages.po index 7e78e907..efa4ca22 100644 --- a/messages.po +++ b/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-08-24 21:44-0400\n" +"POT-Creation-Date: 2018-09-01 16:26-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -501,7 +501,7 @@ msgstr "" msgid "Install" msgstr "" -#: lib/extensions/install.py:40 lib/extensions/params.py:380 +#: lib/extensions/install.py:40 lib/extensions/params.py:411 msgid "Cancel" msgstr "" @@ -557,94 +557,104 @@ msgstr "" msgid "Please choose one or more commands to attach." msgstr "" -#: lib/extensions/params.py:244 +#: lib/extensions/params.py:252 msgid "These settings will be applied to 1 object." msgstr "" -#: lib/extensions/params.py:246 +#: lib/extensions/params.py:254 #, python-format msgid "These settings will be applied to %d objects." msgstr "" -#: lib/extensions/params.py:249 +#: lib/extensions/params.py:257 msgid "" "Some settings had different values across objects. Select a value from " "the dropdown or enter a new one." msgstr "" -#: lib/extensions/params.py:253 +#: lib/extensions/params.py:261 #, python-format msgid "Disabling this tab will disable the following %d tabs." msgstr "" -#: lib/extensions/params.py:255 +#: lib/extensions/params.py:263 msgid "Disabling this tab will disable the following tab." msgstr "" -#: lib/extensions/params.py:258 +#: lib/extensions/params.py:266 #, python-format msgid "Enabling this tab will disable %s and vice-versa." msgstr "" -#: lib/extensions/params.py:288 +#: lib/extensions/params.py:296 msgid "Inkscape objects" msgstr "" -#: lib/extensions/params.py:346 +#: lib/extensions/params.py:354 +msgid "" +"Click to force this parameter to be saved when you click \"Apply and " +"Quit\"" +msgstr "" + +#: lib/extensions/params.py:362 +msgid "This parameter will be saved when you click \"Apply and Quit\"" +msgstr "" + +#: lib/extensions/params.py:377 msgid "Embroidery Params" msgstr "" -#: lib/extensions/params.py:363 +#: lib/extensions/params.py:394 msgid "Presets" msgstr "" -#: lib/extensions/params.py:368 +#: lib/extensions/params.py:399 msgid "Load" msgstr "" -#: lib/extensions/params.py:371 +#: lib/extensions/params.py:402 msgid "Add" msgstr "" -#: lib/extensions/params.py:374 +#: lib/extensions/params.py:405 msgid "Overwrite" msgstr "" -#: lib/extensions/params.py:377 +#: lib/extensions/params.py:408 msgid "Delete" msgstr "" -#: lib/extensions/params.py:384 +#: lib/extensions/params.py:415 msgid "Use Last Settings" msgstr "" -#: lib/extensions/params.py:387 +#: lib/extensions/params.py:418 msgid "Apply and Quit" msgstr "" -#: lib/extensions/params.py:439 +#: lib/extensions/params.py:470 msgid "Preview" msgstr "" -#: lib/extensions/params.py:458 +#: lib/extensions/params.py:489 msgid "Internal Error" msgstr "" -#: lib/extensions/params.py:511 +#: lib/extensions/params.py:542 msgid "Please enter or select a preset name first." msgstr "" -#: lib/extensions/params.py:511 lib/extensions/params.py:517 -#: lib/extensions/params.py:545 +#: lib/extensions/params.py:542 lib/extensions/params.py:548 +#: lib/extensions/params.py:576 msgid "Preset" msgstr "" -#: lib/extensions/params.py:517 +#: lib/extensions/params.py:548 #, python-format msgid "Preset \"%s\" not found." msgstr "" -#: lib/extensions/params.py:545 +#: lib/extensions/params.py:576 #, python-format msgid "" "Preset \"%s\" already exists. Please use another name or press " -- cgit v1.3.1 From 05327d56dbdcc9392c447fc72ef8dbd5c16f0ddc Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 1 Sep 2018 16:38:53 -0400 Subject: stop showing 'None' in Params --- lib/elements/auto_fill.py | 2 +- lib/extensions/params.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/extensions') diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index cfee6d7d..9801b610 100644 --- a/lib/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -55,7 +55,7 @@ class AutoFill(Fill): def fill_underlay_angle(self): underlay_angle = self.get_float_param("fill_underlay_angle") - if underlay_angle: + if underlay_angle is not None: return math.radians(underlay_angle) else: return self.angle + math.pi / 2.0 diff --git a/lib/extensions/params.py b/lib/extensions/params.py index c301ed1a..f5da7e8b 100644 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -329,7 +329,7 @@ class ParamsTab(ScrolledPanel): input.Bind(wx.EVT_CHECKBOX, self.changed) elif len(param.values) > 1: - input = wx.ComboBox(self, wx.ID_ANY, choices=sorted(param.values), style=wx.CB_DROPDOWN) + input = wx.ComboBox(self, wx.ID_ANY, choices=sorted(str(value) for value in param.values), style=wx.CB_DROPDOWN) input.Bind(wx.EVT_COMBOBOX, self.changed) input.Bind(wx.EVT_TEXT, self.changed) else: @@ -720,7 +720,7 @@ class Params(InkstitchExtension): getter = 'get_param' values = filter(lambda item: item is not None, - (getattr(node, getter)(param.name, str(param.default)) for node in nodes)) + (getattr(node, getter)(param.name, param.default) for node in nodes)) return values -- cgit v1.3.1 From c3d6780bf172cc8fc1a5c35a9fde73e101d37e78 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 1 Sep 2018 19:54:34 -0400 Subject: only save modified values in presets --- lib/extensions/params.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/params.py b/lib/extensions/params.py index f5da7e8b..2e304c7b 100644 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -243,9 +243,7 @@ class ParamsTab(ScrolledPanel): self.update_toggle_state() def save_preset(self, storage): - preset = storage[self.name] = {} - for name, input in self.param_inputs.iteritems(): - preset[name] = input.GetValue() + storage[self.name] = self.get_values() def update_description(self): if len(self.nodes) == 1: -- cgit v1.3.1 From b437b8403c4758813c780b16cebe8357e95a8746 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sun, 9 Sep 2018 00:06:47 -0400 Subject: fix pencil icon path --- lib/extensions/params.py | 4 ++-- lib/utils/paths.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/params.py b/lib/extensions/params.py index 2e304c7b..6012263a 100644 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -17,7 +17,7 @@ from .base import InkstitchExtension from ..i18n import _ from ..stitch_plan import patches_to_stitch_plan from ..elements import EmbroideryElement, Fill, AutoFill, Stroke, SatinColumn -from ..utils import save_stderr, restore_stderr, get_bundled_dir +from ..utils import save_stderr, restore_stderr, get_resource_dir from ..simulator import EmbroiderySimulator from ..commands import is_command @@ -118,7 +118,7 @@ class ParamsTab(ScrolledPanel): self.settings_grid.AddGrowableCol(1, 2) self.settings_grid.SetFlexibleDirection(wx.HORIZONTAL) - self.pencil_icon = wx.Image(os.path.join(get_bundled_dir("icons"), "pencil_20x20.png")).ConvertToBitmap() + self.pencil_icon = wx.Image(os.path.join(get_resource_dir("icons"), "pencil_20x20.png")).ConvertToBitmap() self.__set_properties() self.__do_layout() diff --git a/lib/utils/paths.py b/lib/utils/paths.py index 863e8e69..0da8a154 100644 --- a/lib/utils/paths.py +++ b/lib/utils/paths.py @@ -8,3 +8,9 @@ def get_bundled_dir(name): return realpath(os.path.join(sys._MEIPASS, "..", name)) else: return realpath(os.path.join(dirname(realpath(__file__)), '..', '..', name)) + +def get_resource_dir(name): + if getattr(sys, 'frozen', None) is not None: + return realpath(os.path.join(sys._MEIPASS, name)) + else: + return realpath(os.path.join(dirname(realpath(__file__)), '..', '..', name)) -- cgit v1.3.1