diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2018-03-30 20:37:11 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-30 20:37:11 -0400 |
| commit | 084c5555f21a6e927e4de98fdb66c4c408626f58 (patch) | |
| tree | 91e2da4493f4dcc5243114d3f73296b4a0166543 /embroider_params.py | |
| parent | 1279b3ec47fa9c7eb6540e255b67389644fb0b38 (diff) | |
print through web browser (#127)
* spawn a web server and open a printable view of the design in the user's web browser
* configurable inclusion of client and operator views
* editable fields for color names, client, title, and purchase order number
* groundwork laid to save these parameters back into the SVG
* major refactor of codebase to support printing
* code is organized logically into modules
* added inkstitch logo and branding guidelines
* l10n text extraction now handled by babel
* removed legacy embroider_update extension
* partial fix for #125
Diffstat (limited to 'embroider_params.py')
| -rw-r--r-- | embroider_params.py | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/embroider_params.py b/embroider_params.py index 73c6f479..607dbb2a 100644 --- a/embroider_params.py +++ b/embroider_params.py @@ -8,16 +8,17 @@ import traceback import time from threading import Thread, Event from copy import copy -from cStringIO import StringIO import wx from wx.lib.scrolledpanel import ScrolledPanel from collections import defaultdict -import inkex import inkstitch -from inkstitch import _, Param, EmbroideryElement, get_nodes -from embroider import Fill, AutoFill, Stroke, SatinColumn from functools import partial from itertools import groupby +from inkstitch import _ +from inkstitch.extensions import InkstitchExtension +from inkstitch.stitch_plan import patches_to_stitch_plan +from inkstitch.elements import EmbroideryElement, Fill, AutoFill, Stroke, SatinColumn +from inkstitch.utils import save_stderr, restore_stderr from embroider_simulate import EmbroiderySimulator @@ -412,9 +413,10 @@ class SettingsFrame(wx.Frame): wx.CallAfter(self.refresh_simulator, patches) def refresh_simulator(self, patches): + stitch_plan = patches_to_stitch_plan(patches) if self.simulate_window: self.simulate_window.stop() - self.simulate_window.load(patches=patches) + self.simulate_window.load(stitch_plan=stitch_plan) else: my_rect = self.GetRect() simulator_pos = my_rect.GetTopRight() @@ -428,7 +430,7 @@ class SettingsFrame(wx.Frame): self.simulate_window = EmbroiderySimulator(None, -1, _("Preview"), simulator_pos, size=(300, 300), - patches=patches, + stitch_plan=stitch_plan, on_close=self.simulate_window_closed, target_duration=5, max_width=max_width, @@ -631,10 +633,10 @@ class SettingsFrame(wx.Frame): self.Layout() # end wxGlade -class EmbroiderParams(inkex.Effect): +class EmbroiderParams(InkstitchExtension): def __init__(self, *args, **kwargs): self.cancelled = False - inkex.Effect.__init__(self, *args, **kwargs) + InkstitchExtension.__init__(self, *args, **kwargs) def embroidery_classes(self, node): element = EmbroideryElement(node) @@ -653,7 +655,7 @@ class EmbroiderParams(inkex.Effect): return classes def get_nodes_by_class(self): - nodes = get_nodes(self) + nodes = self.get_nodes() nodes_by_class = defaultdict(list) for z, node in enumerate(nodes): @@ -755,21 +757,6 @@ class EmbroiderParams(inkex.Effect): sys.exit(0) -def save_stderr(): - # GTK likes to spam stderr, which inkscape will show in a dialog. - null = open(os.devnull, 'w') - sys.stderr_dup = os.dup(sys.stderr.fileno()) - os.dup2(null.fileno(), 2) - sys.stderr_backup = sys.stderr - sys.stderr = StringIO() - - -def restore_stderr(): - os.dup2(sys.stderr_dup, 2) - sys.stderr_backup.write(sys.stderr.getvalue()) - sys.stderr = sys.stderr_backup - - # end of class MyFrame if __name__ == "__main__": save_stderr() |
