summaryrefslogtreecommitdiff
path: root/lib/gui/electron.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2019-04-30 20:27:52 -0400
committerGitHub <noreply@github.com>2019-04-30 20:27:52 -0400
commit8152c63ee393de68c7c7f53858792d8385c82463 (patch)
treec5089a63555329434b894f0825d104b5de91437c /lib/gui/electron.py
parent5b6923fe9d8d5f3afb0ef298ad34708e735fc5e5 (diff)
parent953990739b742bdad5221c39b35d47fd530502bb (diff)
use electron for Print PDF UI (#432)
electron proof of concept
Diffstat (limited to 'lib/gui/electron.py')
-rw-r--r--lib/gui/electron.py32
1 files changed, 32 insertions, 0 deletions
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)