Commit 2795a9fb968316334321484d3a984d97d281a5b3
1 parent
46b0e1f5
Exists in
master
and in
6 other branches
ADD: Click in the inv3 file and open project
Showing
2 changed files
with
21 additions
and
10 deletions
Show diff stats
invesalius/i18n.py
@@ -28,8 +28,6 @@ import sys | @@ -28,8 +28,6 @@ import sys | ||
28 | 28 | ||
29 | import utils as utl | 29 | import utils as utl |
30 | 30 | ||
31 | -LANGUAGE_DIR = os.path.abspath(os.path.join('..','locale')) | ||
32 | - | ||
33 | def GetLocales(): | 31 | def GetLocales(): |
34 | """Return a dictionary which defines supported languages""" | 32 | """Return a dictionary which defines supported languages""" |
35 | d = utl.TwoWaysDictionary ({'zh_TW': u'中文', | 33 | d = utl.TwoWaysDictionary ({'zh_TW': u'中文', |
@@ -41,18 +39,18 @@ def GetLocales(): | @@ -41,18 +39,18 @@ def GetLocales(): | ||
41 | 'it_IT':'Italiano', | 39 | 'it_IT':'Italiano', |
42 | 'de_DE': 'Deutsch'}) | 40 | 'de_DE': 'Deutsch'}) |
43 | return d | 41 | return d |
44 | - | 42 | + |
45 | def GetLocaleOS(): | 43 | def GetLocaleOS(): |
46 | """Return language of the operating system.""" | 44 | """Return language of the operating system.""" |
47 | if sys.platform == 'darwin': | 45 | if sys.platform == 'darwin': |
48 | locale.setlocale(locale.LC_ALL, "") | 46 | locale.setlocale(locale.LC_ALL, "") |
49 | return locale.getlocale()[0] | 47 | return locale.getlocale()[0] |
50 | - | 48 | + |
51 | return locale.getdefaultlocale()[0] | 49 | return locale.getdefaultlocale()[0] |
52 | - | 50 | + |
53 | def InstallLanguage(language): | 51 | def InstallLanguage(language): |
54 | - | ||
55 | - lang = gettext.translation('invesalius', LANGUAGE_DIR,\ | 52 | + language_dir = os.path.abspath(os.path.join('..','locale')) |
53 | + lang = gettext.translation('invesalius', language_dir,\ | ||
56 | languages=[language], codeset='utf8') | 54 | languages=[language], codeset='utf8') |
57 | # Using unicode | 55 | # Using unicode |
58 | lang.install(unicode=1) | 56 | lang.install(unicode=1) |
invesalius/invesalius.py
@@ -18,11 +18,15 @@ | @@ -18,11 +18,15 @@ | ||
18 | # detalhes. | 18 | # detalhes. |
19 | #------------------------------------------------------------------------- | 19 | #------------------------------------------------------------------------- |
20 | 20 | ||
21 | + | ||
21 | import multiprocessing | 22 | import multiprocessing |
22 | import optparse as op | 23 | import optparse as op |
23 | import os | 24 | import os |
24 | import sys | 25 | import sys |
25 | 26 | ||
27 | +if sys.platform == 'win32': | ||
28 | + import _winreg | ||
29 | + | ||
26 | import wx | 30 | import wx |
27 | import wx.lib.pubsub as ps | 31 | import wx.lib.pubsub as ps |
28 | 32 | ||
@@ -79,7 +83,7 @@ class SplashScreen(wx.SplashScreen): | @@ -79,7 +83,7 @@ class SplashScreen(wx.SplashScreen): | ||
79 | _ = i18n.InstallLanguage(lang) | 83 | _ = i18n.InstallLanguage(lang) |
80 | 84 | ||
81 | # If no language is set into session file, show dialog so | 85 | # If no language is set into session file, show dialog so |
82 | - # user can select language | 86 | + # user can select language |
83 | else: | 87 | else: |
84 | dialog = lang_dlg.LanguageDialog() | 88 | dialog = lang_dlg.LanguageDialog() |
85 | 89 | ||
@@ -115,12 +119,12 @@ class SplashScreen(wx.SplashScreen): | @@ -115,12 +119,12 @@ class SplashScreen(wx.SplashScreen): | ||
115 | 119 | ||
116 | bmp = wx.Image(path).ConvertToBitmap() | 120 | bmp = wx.Image(path).ConvertToBitmap() |
117 | 121 | ||
118 | - style = wx.SPLASH_TIMEOUT | wx.SPLASH_CENTRE_ON_SCREEN | 122 | + style = wx.SPLASH_TIMEOUT | wx.SPLASH_CENTRE_ON_SCREEN |
119 | wx.SplashScreen.__init__(self, | 123 | wx.SplashScreen.__init__(self, |
120 | bitmap=bmp, | 124 | bitmap=bmp, |
121 | splashStyle=style, | 125 | splashStyle=style, |
122 | milliseconds=1500, | 126 | milliseconds=1500, |
123 | - id=-1, | 127 | + id=-1, |
124 | parent=None) | 128 | parent=None) |
125 | self.Bind(wx.EVT_CLOSE, self.OnClose) | 129 | self.Bind(wx.EVT_CLOSE, self.OnClose) |
126 | 130 | ||
@@ -224,6 +228,15 @@ if __name__ == '__main__': | @@ -224,6 +228,15 @@ if __name__ == '__main__': | ||
224 | if hasattr(sys,"frozen") and sys.frozen == "windows_exe": | 228 | if hasattr(sys,"frozen") and sys.frozen == "windows_exe": |
225 | multiprocessing.freeze_support() | 229 | multiprocessing.freeze_support() |
226 | 230 | ||
231 | + #Click in the .inv3 file support | ||
232 | + root = _winreg.HKEY_CLASSES_ROOT | ||
233 | + key = "InVesalius 3.0\InstallationDir" | ||
234 | + hKey = _winreg.OpenKey (root, key, 0, _winreg.KEY_READ) | ||
235 | + value, type_ = _winreg.QueryValueEx (hKey, "") | ||
236 | + path = os.path.join(value,'dist') | ||
237 | + | ||
238 | + os.chdir(path) | ||
239 | + | ||
227 | # Create raycasting presets' folder, if it doens't exist | 240 | # Create raycasting presets' folder, if it doens't exist |
228 | dirpath = os.path.join(os.path.expanduser('~'), | 241 | dirpath = os.path.join(os.path.expanduser('~'), |
229 | ".invesalius", | 242 | ".invesalius", |