docutil/docsvg.py
author Edouard Tisserant <edouard@beremiz.fr>
Thu, 05 Dec 2024 16:45:37 +0100
changeset 4061 e0dfe8b8db4a
parent 3901 b8b3573475e7
permissions -rw-r--r--
py_ext: rework logic CSV reader FB output refresh logic.

Saving with CSV write FB now triggers CSV read FBs to refresh outputs immediately.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     1
#!/usr/bin/env python
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     3
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     6
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
     7
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     8
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
     9
# See COPYING file for copyrights details.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    10
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    11
# This program is free software; you can redistribute it and/or
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    12
# modify it under the terms of the GNU General Public License
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    13
# as published by the Free Software Foundation; either version 2
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    14
# of the License, or (at your option) any later version.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    15
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    16
# This program is distributed in the hope that it will be useful,
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    19
# GNU General Public License for more details.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    20
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    21
# You should have received a copy of the GNU General Public License
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    22
# along with this program; if not, write to the Free Software
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 814
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    24
1881
091005ec69c4 fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1876
diff changeset
    25
3750
f62625418bff automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents: 3573
diff changeset
    26
3573
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
    27
import os
3817
3deeda82636a Fix Py3 problems with basic SVGHMI build and run.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3750
diff changeset
    28
import sys
3111
5d9ae04ee50f Docutil : reworked Inkscape launching and path resolution in docsvg.py
Edouard Tisserant
parents: 2705
diff changeset
    29
import wx
1732
94ffe74e6895 clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    30
import subprocess
3573
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
    31
from dialogs import MessageBoxOnce
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1735
diff changeset
    32
3482
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    33
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    34
def _get_inkscape_path():
3111
5d9ae04ee50f Docutil : reworked Inkscape launching and path resolution in docsvg.py
Edouard Tisserant
parents: 2705
diff changeset
    35
    """ Return the Inkscape binary path """
5d9ae04ee50f Docutil : reworked Inkscape launching and path resolution in docsvg.py
Edouard Tisserant
parents: 2705
diff changeset
    36
3817
3deeda82636a Fix Py3 problems with basic SVGHMI build and run.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3750
diff changeset
    37
    if sys.platform.startswith('win32'):
3deeda82636a Fix Py3 problems with basic SVGHMI build and run.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3750
diff changeset
    38
        import winreg
3111
5d9ae04ee50f Docutil : reworked Inkscape launching and path resolution in docsvg.py
Edouard Tisserant
parents: 2705
diff changeset
    39
        inkcmd = None
3477
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    40
        tries = [(winreg.HKEY_LOCAL_MACHINE, 'Software\\Classes\\svgfile\\shell\\Inkscape\\command'),
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    41
                 (winreg.HKEY_LOCAL_MACHINE, 'Software\\Classes\\inkscape.svg\\shell\\open\\command'),
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    42
                 (winreg.HKEY_CURRENT_USER, 'Software\\Classes\\inkscape.svg\\shell\\open\\command')]
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    43
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    44
        for subreg, key in tries:
2705
889ec6db6f7d docsvg.py : Better error message when inkscape is not installed.
Edouard Tisserant
parents: 2628
diff changeset
    45
            try:
3477
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    46
                inkcmd = winreg.QueryValue(subreg, key)
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    47
                break;
3111
5d9ae04ee50f Docutil : reworked Inkscape launching and path resolution in docsvg.py
Edouard Tisserant
parents: 2705
diff changeset
    48
            except OSError:
3477
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    49
                pass
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    50
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    51
        if inkcmd is None:
9ec5ecf9f589 IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3111
diff changeset
    52
            return None
2705
889ec6db6f7d docsvg.py : Better error message when inkscape is not installed.
Edouard Tisserant
parents: 2628
diff changeset
    53
3901
b8b3573475e7 Fix SVGHMI build exception on windows: return bytes for inkscape path in docsvg.
Edouard Tisserant <edouard@beremiz.fr>
parents: 3890
diff changeset
    54
        return inkcmd.replace('"%1"', '').strip().replace('"', '').encode()
3111
5d9ae04ee50f Docutil : reworked Inkscape launching and path resolution in docsvg.py
Edouard Tisserant
parents: 2705
diff changeset
    55
2628
40c4449001df Allow using docutil.get_inkscape_path() on Linux also.
Edouard Tisserant
parents: 2431
diff changeset
    56
    else:
3111
5d9ae04ee50f Docutil : reworked Inkscape launching and path resolution in docsvg.py
Edouard Tisserant
parents: 2705
diff changeset
    57
        try:
5d9ae04ee50f Docutil : reworked Inkscape launching and path resolution in docsvg.py
Edouard Tisserant
parents: 2705
diff changeset
    58
            return subprocess.check_output("command -v inkscape", shell=True).strip()
5d9ae04ee50f Docutil : reworked Inkscape launching and path resolution in docsvg.py
Edouard Tisserant
parents: 2705
diff changeset
    59
        except subprocess.CalledProcessError:
5d9ae04ee50f Docutil : reworked Inkscape launching and path resolution in docsvg.py
Edouard Tisserant
parents: 2705
diff changeset
    60
            return None
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1735
diff changeset
    61
3482
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    62
_inkscape_path = None
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    63
def get_inkscape_path():
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    64
    """ Return the Inkscape binary path """
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    65
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    66
    global _inkscape_path
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    67
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    68
    if _inkscape_path is not None:
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    69
        return _inkscape_path
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    70
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    71
    _inkscape_path = _get_inkscape_path()
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    72
    return _inkscape_path
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    73
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    74
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    75
def _get_inkscape_version():
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    76
    inkpath = get_inkscape_path()
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    77
    if inkpath is None:
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    78
        return None
3890
6d2d37975c7c docsvg: safer version checking of Inkscape
Edouard Tisserant <edouard@beremiz.fr>
parents: 3818
diff changeset
    79
    version_string = subprocess.check_output(
6d2d37975c7c docsvg: safer version checking of Inkscape
Edouard Tisserant <edouard@beremiz.fr>
parents: 3818
diff changeset
    80
            [inkpath,"--version"], 
6d2d37975c7c docsvg: safer version checking of Inkscape
Edouard Tisserant <edouard@beremiz.fr>
parents: 3818
diff changeset
    81
            stderr=subprocess.STDOUT)
6d2d37975c7c docsvg: safer version checking of Inkscape
Edouard Tisserant <edouard@beremiz.fr>
parents: 3818
diff changeset
    82
    if version_string:
6d2d37975c7c docsvg: safer version checking of Inkscape
Edouard Tisserant <edouard@beremiz.fr>
parents: 3818
diff changeset
    83
        return list(map(int,version_string.split()[1].split(b'.')))
6d2d37975c7c docsvg: safer version checking of Inkscape
Edouard Tisserant <edouard@beremiz.fr>
parents: 3818
diff changeset
    84
    return [0,0]
3482
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    85
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    86
_inkscape_version = None
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    87
def get_inkscape_version():
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    88
    global _inkscape_version
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    89
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    90
    if _inkscape_version is not None:
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    91
        return _inkscape_version
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    92
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    93
    _inkscape_version = _get_inkscape_version()
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    94
    return _inkscape_version
31f6d7221f60 SVGHMI: Adapt to Inkscape 0.92 "-e" replaced by "-o" in 1.2, and workaround access right problem when generating thumbnails.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3477
diff changeset
    95
3750
f62625418bff automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents: 3573
diff changeset
    96
if "SNAP" in os.environ:
3573
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
    97
    def open_svg(svgfile):
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
    98
        MessageBoxOnce("Launching Inkscape with xdg-open",
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
    99
                "Confined app can't launch Inkscape directly.\n"+
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   100
                    "Instead, SVG file is passed to xdg-open.\n"+
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   101
                    "Please select Inskape when proposed.\n\n"+
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   102
                    "Notes: \n"+
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   103
                    " - Inkscape must be installed on you system.\n"+
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   104
                    " - If no choice is proposed, use file manager to change SVG file properties.\n",
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   105
                "DocSVGSnapWarning")
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   106
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   107
        subprocess.Popen(["xdg-open",svgfile])
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   108
else:
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   109
    def open_svg(svgfile):
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   110
        """ Generic function to open SVG file """
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   111
        inkpath = get_inkscape_path()
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   112
        if inkpath is None:
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   113
            wx.MessageBox("Inkscape is not found or installed !")
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   114
        else:
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3482
diff changeset
   115
            subprocess.Popen([inkpath,svgfile])