29 import wx |
29 import wx |
30 |
30 |
31 |
31 |
32 def get_inkscape_path(): |
32 def get_inkscape_path(): |
33 """ Return the Inkscape path """ |
33 """ Return the Inkscape path """ |
34 from six.moves import winreg |
34 if wx.Platform == '__WXMSW__': |
35 try: |
35 from six.moves import winreg |
36 svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, |
36 try: |
37 'Software\\Classes\\svgfile\\shell\\Inkscape\\command') |
37 svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, |
38 except OSError: |
38 'Software\\Classes\\svgfile\\shell\\Inkscape\\command') |
39 svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, |
39 except OSError: |
40 'Software\\Classes\\inkscape.svg\\shell\\open\\command') |
40 svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, |
41 svgexepath = svgexepath.replace('"%1"', '') |
41 'Software\\Classes\\inkscape.svg\\shell\\open\\command') |
42 return svgexepath.replace('"', '') |
42 svgexepath = svgexepath.replace('"%1"', '').strip() |
|
43 return svgexepath.replace('"', '') |
|
44 else: |
|
45 # TODO: search path |
|
46 return os.path.join("/usr/bin", "inkscape") |
43 |
47 |
44 |
48 |
45 def open_win_svg(svgexepath, svgfile): |
49 def open_win_svg(svgexepath, svgfile): |
46 """ Open Inkscape on Windows platform """ |
50 """ Open Inkscape on Windows platform """ |
47 popenargs = [svgexepath] |
51 popenargs = [svgexepath] |
63 open_win_svg(get_inkscape_path(), svgfile) |
67 open_win_svg(get_inkscape_path(), svgfile) |
64 except Exception: |
68 except Exception: |
65 wx.MessageBox("Inkscape is not found or installed !") |
69 wx.MessageBox("Inkscape is not found or installed !") |
66 return None |
70 return None |
67 else: |
71 else: |
68 svgexepath = os.path.join("/usr/bin", "inkscape") |
72 svgexepath=get_inkscape_path() |
69 if os.path.isfile(svgexepath): |
73 if os.path.isfile(svgexepath): |
70 open_lin_svg(svgexepath, svgfile) |
74 open_lin_svg(svgexepath, svgfile) |
71 else: |
75 else: |
72 wx.MessageBox("Inkscape is not found or installed !") |
76 wx.MessageBox("Inkscape is not found or installed !") |
73 return None |
77 return None |