diff options
| author | Lex Neva <github.com@lexneva.name> | 2019-04-18 11:35:29 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2019-04-18 11:35:29 -0400 |
| commit | fee43e0941b11c709d7ae23fcd4bee4cd89d2a55 (patch) | |
| tree | 35a083ac02458452e0098c32639c0e0ce1939236 | |
| parent | e0c12fbbaa4e05f116a3436617260c6e2d1d2781 (diff) | |
fix parameter management
| -rw-r--r-- | lib/extensions/lettering.py | 18 | ||||
| -rw-r--r-- | lib/utils/dotdict.py | 6 |
2 files changed, 16 insertions, 8 deletions
diff --git a/lib/extensions/lettering.py b/lib/extensions/lettering.py index e6b828a8..17435492 100644 --- a/lib/extensions/lettering.py +++ b/lib/extensions/lettering.py @@ -70,12 +70,6 @@ class LetteringFrame(wx.Frame): def load_settings(self): """Load the settings saved into the SVG group element""" - try: - if INKSTITCH_LETTERING in self.group.attrib: - self.settings = DotDict(json.loads(b64decode(self.group.get(INKSTITCH_LETTERING)))) - return - except (TypeError, ValueError): - pass self.settings = DotDict({ "text": u"", @@ -84,9 +78,16 @@ class LetteringFrame(wx.Frame): "scale": 100 }) + try: + if INKSTITCH_LETTERING in self.group.attrib: + self.settings.update(json.loads(b64decode(self.group.get(INKSTITCH_LETTERING)))) + return + except (TypeError, ValueError): + pass + def apply_settings(self): """Make the settings in self.settings visible in the UI.""" - self.back_and_forth_checkbox.SetValue(self.settings.back_and_forth) + self.back_and_forth_checkbox.SetValue(bool(self.settings.back_and_forth)) self.trim_checkbox.SetValue(bool(self.settings.trim)) self.set_initial_font(self.settings.font) self.text_editor.SetValue(self.settings.text) @@ -143,7 +144,7 @@ class LetteringFrame(wx.Frame): return {font.name: font.description for font in self.fonts.itervalues()} def set_initial_font(self, font_id): - if font_id is not None: + if font_id: if font_id not in self.fonts_by_id: info_dialog(self, _( '''This text was created using the font "%s", but Ink/Stitch can't find that font. A default font will be substituted.''') % font_id) @@ -169,6 +170,7 @@ class LetteringFrame(wx.Frame): def on_font_changed(self, event=None): font = self.fonts.get(self.font_chooser.GetValue(), self.default_font) + self.settings.font = font.id self.scale_spinner.SetRange(int(font.min_scale * 100), int(font.max_scale * 100)) self.update_preview() diff --git a/lib/utils/dotdict.py b/lib/utils/dotdict.py index 1ab3a4fe..76f23697 100644 --- a/lib/utils/dotdict.py +++ b/lib/utils/dotdict.py @@ -6,7 +6,13 @@ class DotDict(dict): def __init__(self, *args, **kwargs): super(DotDict, self).__init__(*args, **kwargs) + self._dotdictify() + def update(self, *args, **kwargs): + super(DotDict, self).update(*args, **kwargs) + self.dotdictify() + + def _dotdictify(self): for k, v in self.iteritems(): if isinstance(v, dict): self[k] = DotDict(v) |
