author | Surkov Sergey <surkovsv93@gmail.com> |
Mon, 26 Jun 2017 19:42:42 +0300 | |
changeset 1708 | 24416137cda7 |
parent 1571 | 486f94a8032c |
child 1732 | 94ffe74e6895 |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
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 | 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 | 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 | 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 | 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 | 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 | 24 |
|
25 |
import wx, os, subprocess |
|
26 |
||
27 |
def get_inkscape_path(): |
|
28 |
""" Return the Inkscape path """ |
|
29 |
import _winreg |
|
30 |
svgexepath = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, |
|
31 |
'Software\\Classes\\svgfile\\shell\\Inkscape\\command') |
|
32 |
svgexepath = svgexepath.replace('"%1"', '') |
|
33 |
return svgexepath.replace('"', '') |
|
34 |
||
35 |
def open_win_svg(svgexepath, svgfile): |
|
36 |
""" Open Inkscape on Windows platform """ |
|
37 |
popenargs = [svgexepath] |
|
38 |
if svgfile is not None : |
|
39 |
popenargs.append(svgfile) |
|
40 |
subprocess.Popen(popenargs).pid |
|
41 |
||
42 |
def open_lin_svg(svgexepath, svgfile): |
|
43 |
""" Open Inkscape on Linux platform """ |
|
44 |
if os.path.isfile("/usr/bin/inkscape"): |
|
45 |
os.system("%s %s &"%(svgexepath , svgfile)) |
|
46 |
||
47 |
def open_svg(svgfile): |
|
48 |
""" Generic function to open SVG file """ |
|
49 |
if wx.Platform == '__WXMSW__' : |
|
50 |
try: |
|
51 |
open_win_svg(get_inkscape_path(), svgfile) |
|
52 |
except: |
|
53 |
wx.MessageBox("Inkscape is not found or installed !") |
|
54 |
return None |
|
55 |
else: |
|
56 |
svgexepath = os.path.join("/usr/bin","inkscape") |
|
57 |
if(os.path.isfile(svgexepath)): |
|
58 |
open_lin_svg(svgexepath, svgfile) |
|
59 |
else: |
|
60 |
wx.MessageBox("Inkscape is not found or installed !") |
|
61 |
return None |
|
62 |