summaryrefslogtreecommitdiff
path: root/lib/gui
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gui')
-rw-r--r--lib/gui/__init__.py1
-rw-r--r--lib/gui/electron.py32
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/gui/__init__.py b/lib/gui/__init__.py
index 51890cf9..2214db5d 100644
--- a/lib/gui/__init__.py
+++ b/lib/gui/__init__.py
@@ -1,4 +1,5 @@
from dialogs import info_dialog, confirm_dialog
+from electron import open_url
from presets import PresetsPanel
from simulator import EmbroiderySimulator, SimulatorPreview, show_simulator
from subtitle_combo_box import SubtitleComboBox
diff --git a/lib/gui/electron.py b/lib/gui/electron.py
new file mode 100644
index 00000000..6bff15aa
--- /dev/null
+++ b/lib/gui/electron.py
@@ -0,0 +1,32 @@
+import os
+import subprocess
+import sys
+
+from ..utils import get_bundled_dir
+
+
+app_process = None
+
+
+def open_url(url):
+ global app
+
+ command = []
+ cwd = None
+
+ if getattr(sys, 'frozen', None) is not None:
+ electron_path = os.path.join(get_bundled_dir("electron"), "inkstitch-gui")
+
+ if sys.platform == "darwin":
+ electron_path += ".app/Contents/MacOS/inkstitch-gui"
+ command = ["open", "-a", electron_path, "--args", url]
+ else:
+ command = [electron_path, url]
+ else:
+ # if we're not running in a pyinstaller bundle, run electron directly
+ command = ["yarn", "dev", url]
+ cwd = get_bundled_dir("electron")
+
+ # Any output on stdout will crash inkscape.
+ null = open(os.devnull, 'w')
+ return subprocess.Popen(command, cwd=cwd, stdout=null)