diff --git a/.gitignore b/.gitignore index 1c1511d9..2c093ca3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ __pycache__ build +dist *.egg-info .vs *.tikz @@ -11,4 +12,4 @@ build *.zxp *.qasm .env -*.zxr \ No newline at end of file +*.zxr diff --git a/zxlive.py b/zxlive.py new file mode 100644 index 00000000..eea7c234 --- /dev/null +++ b/zxlive.py @@ -0,0 +1,4 @@ +from zxlive import app + +if __name__ == '__main__': + app.main() diff --git a/zxlive.spec b/zxlive.spec new file mode 100644 index 00000000..e493c7e4 --- /dev/null +++ b/zxlive.spec @@ -0,0 +1,46 @@ +# -*- mode: python ; coding: utf-8 -*- + +# To create executable, run: +# pyinstaller zxlive.spec +# This will create a directory called "dist" containing the executable for the host OS. + + +a = Analysis( + ['zxlive.py'], + pathex=[], + binaries=[], + datas=[('zxlive/icons/magic-wand.svg', 'zxlive/icons'), + ('zxlive/icons/tikzit-tool-edge.svg', 'zxlive/icons'), + ('zxlive/icons/tikzit-tool-node.svg', 'zxlive/icons'), + ('zxlive/icons/tikzit-tool-select.svg', 'zxlive/icons'), + ('zxlive/icons/undo.svg', 'zxlive/icons'), + ('zxlive/icons/redo.svg', 'zxlive/icons')], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='zxlive', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) diff --git a/zxlive/common.py b/zxlive/common.py index 3a6fa4f2..a2029eb7 100644 --- a/zxlive/common.py +++ b/zxlive/common.py @@ -6,8 +6,10 @@ _ROOT = os.path.abspath(os.path.dirname(__file__)) + def get_data(path: str) -> str: - return os.path.join(_ROOT, path) + return os.path.join(os.environ.get("_MEIPASS", _ROOT), path) + CUSTOM_RULES_PATH: Final = "lemmas/" diff --git a/zxlive/dialogs.py b/zxlive/dialogs.py index d0162867..19c3de06 100644 --- a/zxlive/dialogs.py +++ b/zxlive/dialogs.py @@ -118,7 +118,11 @@ def import_diagram_from_file(file_path: str, selected_filter: str = FileFormat.A selected_format = next(f for f in FileFormat if f.filter == selected_filter) if selected_format == FileFormat.All: ext = file_path.split(".")[-1] - selected_format = next(f for f in FileFormat if f.extension == ext) + try: + selected_format = next(f for f in FileFormat if f.extension == ext) + except StopIteration: + show_error_msg("Failed to import file", f"Couldn't determine filetype: {file_path}.") + return None # TODO: This would be nicer with match statements (requires python 3.10 though)... try: diff --git a/zxlive/icons/redo.svg b/zxlive/icons/redo.svg index 958e947a..4b02d05f 100644 --- a/zxlive/icons/redo.svg +++ b/zxlive/icons/redo.svg @@ -5,35 +5,11 @@ viewBox="0 0 60 60" version="1.1" id="svg4" - sodipodi:docname="undo.svg" - inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns="http://www.w3.org/2000/svg" - xmlns:svg="http://www.w3.org/2000/svg"> + xmlns="http://www.w3.org/2000/svg"> - diff --git a/zxlive/icons/tikzit-tool-edge.svg b/zxlive/icons/tikzit-tool-edge.svg index eafc4231..5c2740a2 100644 --- a/zxlive/icons/tikzit-tool-edge.svg +++ b/zxlive/icons/tikzit-tool-edge.svg @@ -1,6 +1,5 @@ - -