diff --git a/inkstitch.py b/inkstitch.py index bd3f3f488..fe8d6ecb4 100644 --- a/inkstitch.py +++ b/inkstitch.py @@ -5,15 +5,11 @@ from inkstitch.utils import save_stderr, restore_stderr from inkstitch import extensions -def get_extension(): - parser = ArgumentParser() - parser.add_argument("--extension") - args, extras = parser.parse_known_args() +parser = ArgumentParser() +parser.add_argument("--extension") +my_args, remaining_args = parser.parse_known_args() - return args.extension - - -extension_name = get_extension() +extension_name = my_args.extension extension_class = getattr(extensions, extension_name.capitalize()) extension = extension_class() @@ -21,7 +17,7 @@ exception = None save_stderr() try: - extension.affect() + extension.affect(args=remaining_args) except (SystemExit, KeyboardInterrupt): raise except Exception: diff --git a/inkstitch/extensions/__init__.py b/inkstitch/extensions/__init__.py index 20449866e..4c8317d01 100644 --- a/inkstitch/extensions/__init__.py +++ b/inkstitch/extensions/__init__.py @@ -1,5 +1,5 @@ from embroider import Embroider from palettes import Palettes from params import Params -from print import Print +from print_pdf import Print from simulate import Simulate diff --git a/inkstitch/extensions/params.py b/inkstitch/extensions/params.py index a9bff6cc8..881dab496 100644 --- a/inkstitch/extensions/params.py +++ b/inkstitch/extensions/params.py @@ -1,3 +1,5 @@ +# -*- coding: UTF-8 -*- + import os import sys import json @@ -630,7 +632,7 @@ class SettingsFrame(wx.Frame): self.Layout() # end wxGlade -class EmbroiderParams(InkstitchExtension): +class Params(InkstitchExtension): def __init__(self, *args, **kwargs): self.cancelled = False InkstitchExtension.__init__(self, *args, **kwargs) diff --git a/inkstitch/extensions/print.py b/inkstitch/extensions/print_pdf.py similarity index 98% rename from inkstitch/extensions/print.py rename to inkstitch/extensions/print_pdf.py index 0241639e3..5d462c0f4 100644 --- a/inkstitch/extensions/print.py +++ b/inkstitch/extensions/print_pdf.py @@ -106,7 +106,7 @@ class PrintPreviewServer(Thread): if getattr(sys, 'frozen', False): self.resources_path = os.path.join(sys._MEIPASS, 'print', 'resources') else: - self.resources_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'print', 'resources') + self.resources_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..', 'print', 'resources')) def __setup_app(self): self.__set_resources_path() @@ -283,7 +283,7 @@ class Print(InkstitchExtension): if getattr( sys, 'frozen', False ) : template_dir = os.path.join(sys._MEIPASS, "print", "templates") else: - template_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "print", "templates") + template_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "print", "templates")) env = Environment( loader = FileSystemLoader(template_dir), diff --git a/inkstitch/extensions/simulate.py b/inkstitch/extensions/simulate.py index 377649c3c..75bc62c75 100644 --- a/inkstitch/extensions/simulate.py +++ b/inkstitch/extensions/simulate.py @@ -1,3 +1,5 @@ +import wx + from .base import InkstitchExtension from ..simulator import EmbroiderySimulator from ..stitch_plan import patches_to_stitch_plan diff --git a/inkstitch/simulator.py b/inkstitch/simulator.py index dc60e4d87..cc9442eaf 100644 --- a/inkstitch/simulator.py +++ b/inkstitch/simulator.py @@ -1,11 +1,11 @@ +import sys import numpy import wx import colorsys from itertools import izip -from .base import InkstitchExtension -from .. import PIXELS_PER_MM -from ..svg import color_block_to_point_lists +from . import PIXELS_PER_MM +from .svg import color_block_to_point_lists class EmbroiderySimulator(wx.Frame):