Commit 2795a9fb968316334321484d3a984d97d281a5b3

Authored by Paulo Henrique Junqueira Amorim
1 parent 46b0e1f5

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 28  
29 29 import utils as utl
30 30  
31   -LANGUAGE_DIR = os.path.abspath(os.path.join('..','locale'))
32   -
33 31 def GetLocales():
34 32 """Return a dictionary which defines supported languages"""
35 33 d = utl.TwoWaysDictionary ({'zh_TW': u'中文',
... ... @@ -41,18 +39,18 @@ def GetLocales():
41 39 'it_IT':'Italiano',
42 40 'de_DE': 'Deutsch'})
43 41 return d
44   -
  42 +
45 43 def GetLocaleOS():
46 44 """Return language of the operating system."""
47 45 if sys.platform == 'darwin':
48 46 locale.setlocale(locale.LC_ALL, "")
49 47 return locale.getlocale()[0]
50   -
  48 +
51 49 return locale.getdefaultlocale()[0]
52   -
  50 +
53 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 54 languages=[language], codeset='utf8')
57 55 # Using unicode
58 56 lang.install(unicode=1)
... ...
invesalius/invesalius.py
... ... @@ -18,11 +18,15 @@
18 18 # detalhes.
19 19 #-------------------------------------------------------------------------
20 20  
  21 +
21 22 import multiprocessing
22 23 import optparse as op
23 24 import os
24 25 import sys
25 26  
  27 +if sys.platform == 'win32':
  28 + import _winreg
  29 +
26 30 import wx
27 31 import wx.lib.pubsub as ps
28 32  
... ... @@ -79,7 +83,7 @@ class SplashScreen(wx.SplashScreen):
79 83 _ = i18n.InstallLanguage(lang)
80 84  
81 85 # If no language is set into session file, show dialog so
82   - # user can select language
  86 + # user can select language
83 87 else:
84 88 dialog = lang_dlg.LanguageDialog()
85 89  
... ... @@ -115,12 +119,12 @@ class SplashScreen(wx.SplashScreen):
115 119  
116 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 123 wx.SplashScreen.__init__(self,
120 124 bitmap=bmp,
121 125 splashStyle=style,
122 126 milliseconds=1500,
123   - id=-1,
  127 + id=-1,
124 128 parent=None)
125 129 self.Bind(wx.EVT_CLOSE, self.OnClose)
126 130  
... ... @@ -224,6 +228,15 @@ if __name__ == '__main__':
224 228 if hasattr(sys,"frozen") and sys.frozen == "windows_exe":
225 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 240 # Create raycasting presets' folder, if it doens't exist
228 241 dirpath = os.path.join(os.path.expanduser('~'),
229 242 ".invesalius",
... ...