From 8f6652dbef562a5b0f865085941d5a5095d8babc Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Thu, 2 Aug 2018 22:05:42 -0400 Subject: set stdout to binary mode on windows --- lib/extensions/output.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/extensions') diff --git a/lib/extensions/output.py b/lib/extensions/output.py index 1dc8d19d..e72eac7b 100644 --- a/lib/extensions/output.py +++ b/lib/extensions/output.py @@ -36,6 +36,10 @@ class Output(InkstitchExtension): write_embroidery_file(temp_file.name, stitch_plan, self.document.getroot()) + if sys.platform == "win32": + import msvcrt + msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) + # inkscape will read the file contents from stdout and copy # to the destination file that the user chose with open(temp_file.name) as output_file: -- cgit v1.2.3 From b7c5a594ddded90c6ff9233825ac280aa7eb0367 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 3 Aug 2018 21:50:54 -0400 Subject: debug --- lib/extensions/output.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/extensions') diff --git a/lib/extensions/output.py b/lib/extensions/output.py index e72eac7b..bae0998c 100644 --- a/lib/extensions/output.py +++ b/lib/extensions/output.py @@ -37,6 +37,7 @@ class Output(InkstitchExtension): write_embroidery_file(temp_file.name, stitch_plan, self.document.getroot()) if sys.platform == "win32": + print >> sys.stderr, "setting stdout to binary mode" import msvcrt msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) @@ -44,6 +45,7 @@ class Output(InkstitchExtension): # to the destination file that the user chose with open(temp_file.name) as output_file: sys.stdout.write(output_file.read()) + sys.stdout.flush() # clean up the temp file os.remove(temp_file.name) -- cgit v1.2.3 From 782b5efc71ab63a6becd7aa846feed5ea48a678a Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 3 Aug 2018 22:11:13 -0400 Subject: read in binary too --- lib/extensions/output.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/output.py b/lib/extensions/output.py index bae0998c..f3bb0a80 100644 --- a/lib/extensions/output.py +++ b/lib/extensions/output.py @@ -37,13 +37,12 @@ class Output(InkstitchExtension): write_embroidery_file(temp_file.name, stitch_plan, self.document.getroot()) if sys.platform == "win32": - print >> sys.stderr, "setting stdout to binary mode" import msvcrt msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) # inkscape will read the file contents from stdout and copy # to the destination file that the user chose - with open(temp_file.name) as output_file: + with open(temp_file.name, "rb") as output_file: sys.stdout.write(output_file.read()) sys.stdout.flush() -- cgit v1.2.3 From b9943cb44f4b07f7fe52f126810accf91f6a05cd Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Fri, 17 Aug 2018 07:16:34 +0200 Subject: Improve Simulator (#261) * open simulator on the screen with the mouse cursor on * fix simulator positioning in mac * simulator shortcut keys: closes #97, closes #21 --- lib/extensions/params.py | 20 ++++++++++++++++---- lib/extensions/simulate.py | 9 +++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/params.py b/lib/extensions/params.py index 1b8f2589..c464e044 100644 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -424,18 +424,22 @@ class SettingsFrame(wx.Frame): self.simulate_window.stop() self.simulate_window.load(stitch_plan=stitch_plan) else: - my_rect = self.GetScreenRect() - simulator_pos = my_rect.GetTopRight() + params_rect = self.GetScreenRect() + simulator_pos = params_rect.GetTopRight() simulator_pos.x += 5 - screen_rect = wx.Display(0).ClientArea - max_width = screen_rect.GetWidth() - my_rect.GetWidth() + current_screen = wx.Display.GetFromPoint(wx.GetMousePosition()) + display = wx.Display(current_screen) + screen_rect = display.GetClientArea() + + max_width = screen_rect.GetWidth() - params_rect.GetWidth() max_height = screen_rect.GetHeight() try: self.simulate_window = EmbroiderySimulator(None, -1, _("Preview"), simulator_pos, size=(300, 300), + x_position=simulator_pos.x, stitch_plan=stitch_plan, on_close=self.simulate_window_closed, target_duration=5, @@ -764,6 +768,14 @@ class Params(InkstitchExtension): try: app = wx.App() frame = SettingsFrame(tabs_factory=self.create_tabs, on_cancel=self.cancel) + + # position left, center + current_screen = wx.Display.GetFromPoint(wx.GetMousePosition()) + display = wx.Display(current_screen) + display_size = display.GetClientArea() + frame_size = frame.GetSize() + frame.SetPosition((display_size[0], display_size[3] / 2 - frame_size[1] / 2)) + frame.Show() app.MainLoop() diff --git a/lib/extensions/simulate.py b/lib/extensions/simulate.py index 0c372d4d..38f86156 100644 --- a/lib/extensions/simulate.py +++ b/lib/extensions/simulate.py @@ -17,11 +17,16 @@ class Simulate(InkstitchExtension): def effect(self): if not self.get_elements(): return - patches = self.elements_to_patches(self.elements) stitch_plan = patches_to_stitch_plan(patches) app = wx.App() - frame = EmbroiderySimulator(None, -1, _("Embroidery Simulation"), wx.DefaultPosition, size=(1000, 1000), stitch_plan=stitch_plan) + current_screen = wx.Display.GetFromPoint(wx.GetMousePosition()) + display = wx.Display(current_screen) + screen_rect = display.GetClientArea() + + simulator_pos = (screen_rect[0], screen_rect[1]) + + frame = EmbroiderySimulator(None, -1, _("Embroidery Simulation"), pos=simulator_pos, size=(1000, 1000), stitch_plan=stitch_plan) app.SetTopWindow(frame) frame.Show() wx.CallAfter(frame.go) -- cgit v1.2.3