Commit 198def5c9858c79936e5994c03af84975d2750e2
1 parent
eed9bb86
Exists in
master
and in
68 other branches
FIX: Not exist ".invesalius" folder #FIX: 103
Showing
1 changed file
with
35 additions
and
30 deletions
Show diff stats
invesalius/invesalius.py
@@ -46,12 +46,13 @@ import wx.lib.pubsub as ps | @@ -46,12 +46,13 @@ import wx.lib.pubsub as ps | ||
46 | class SplashScreen(wx.SplashScreen): | 46 | class SplashScreen(wx.SplashScreen): |
47 | def __init__(self): | 47 | def __init__(self): |
48 | 48 | ||
49 | + save_session = False | ||
49 | session = Session() | 50 | session = Session() |
50 | if not (session.ReadSession()): | 51 | if not (session.ReadSession()): |
51 | - session.CreateItens() | ||
52 | - | 52 | + save_session = True |
53 | + | ||
53 | if not(session.ReadLanguage()): | 54 | if not(session.ReadLanguage()): |
54 | - | 55 | + |
55 | ldlg = lang_dlg.LanguageDialog() | 56 | ldlg = lang_dlg.LanguageDialog() |
56 | 57 | ||
57 | try: | 58 | try: |
@@ -63,25 +64,29 @@ class SplashScreen(wx.SplashScreen): | @@ -63,25 +64,29 @@ class SplashScreen(wx.SplashScreen): | ||
63 | lang = ldlg.GetSelectedLanguage() | 64 | lang = ldlg.GetSelectedLanguage() |
64 | session.SetLanguage(lang) | 65 | session.SetLanguage(lang) |
65 | _ = i18n.InstallLanguage(lang) | 66 | _ = i18n.InstallLanguage(lang) |
66 | - | ||
67 | else: | 67 | else: |
68 | lang = session.GetLanguage() | 68 | lang = session.GetLanguage() |
69 | _ = i18n.InstallLanguage(lang) | 69 | _ = i18n.InstallLanguage(lang) |
70 | - | 70 | + |
71 | + if (save_session): | ||
72 | + session.CreateItens() | ||
73 | + session.SetLanguage(lang) | ||
74 | + session.CreateSessionFile() | ||
75 | + | ||
71 | if (lang.startswith('pt')): #Necessy, pt noted as pt_BR | 76 | if (lang.startswith('pt')): #Necessy, pt noted as pt_BR |
72 | icon_file = "splash_pt.png" | 77 | icon_file = "splash_pt.png" |
73 | else: | 78 | else: |
74 | icon_file = "splash_" + lang + ".png" | 79 | icon_file = "splash_" + lang + ".png" |
75 | - | 80 | + |
76 | path = os.path.join("..","icons", icon_file) | 81 | path = os.path.join("..","icons", icon_file) |
77 | - | 82 | + |
78 | bmp = wx.Image(path).ConvertToBitmap() | 83 | bmp = wx.Image(path).ConvertToBitmap() |
79 | - | 84 | + |
80 | wx.SplashScreen.__init__(self, bitmap=bmp, | 85 | wx.SplashScreen.__init__(self, bitmap=bmp, |
81 | splashStyle=wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, | 86 | splashStyle=wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, |
82 | milliseconds=1500, id=-1, parent=None) | 87 | milliseconds=1500, id=-1, parent=None) |
83 | self.Bind(wx.EVT_CLOSE, self.OnClose) | 88 | self.Bind(wx.EVT_CLOSE, self.OnClose) |
84 | - | 89 | + |
85 | from gui.frame import Frame | 90 | from gui.frame import Frame |
86 | from control import Controller | 91 | from control import Controller |
87 | from project import Project | 92 | from project import Project |
@@ -97,20 +102,20 @@ class SplashScreen(wx.SplashScreen): | @@ -97,20 +102,20 @@ class SplashScreen(wx.SplashScreen): | ||
97 | # destroyed | 102 | # destroyed |
98 | evt.Skip() | 103 | evt.Skip() |
99 | self.Hide() | 104 | self.Hide() |
100 | - | 105 | + |
101 | # if the timer is still running then go ahead and show the | 106 | # if the timer is still running then go ahead and show the |
102 | # main frame now | 107 | # main frame now |
103 | if self.fc.IsRunning(): | 108 | if self.fc.IsRunning(): |
104 | self.fc.Stop() | 109 | self.fc.Stop() |
105 | - | ||
106 | - session = Session() | 110 | + |
111 | + #session = Session() | ||
107 | #if not (session.ReadSession()): | 112 | #if not (session.ReadSession()): |
108 | # session.CreateItens() | 113 | # session.CreateItens() |
109 | - | ||
110 | - lang = session.GetLanguage() | ||
111 | - print lang | ||
112 | - | ||
113 | - i18n.InstallLanguage(lang) | 114 | + |
115 | + #lang = session.GetLanguage() | ||
116 | + #print lang | ||
117 | + | ||
118 | + #i18n.InstallLanguage(lang) | ||
114 | self.ShowMain() | 119 | self.ShowMain() |
115 | 120 | ||
116 | 121 | ||
@@ -119,7 +124,7 @@ class SplashScreen(wx.SplashScreen): | @@ -119,7 +124,7 @@ class SplashScreen(wx.SplashScreen): | ||
119 | 124 | ||
120 | if self.fc.IsRunning(): | 125 | if self.fc.IsRunning(): |
121 | self.Raise() | 126 | self.Raise() |
122 | - | 127 | + |
123 | class InVesalius(wx.App): | 128 | class InVesalius(wx.App): |
124 | def OnInit(self): | 129 | def OnInit(self): |
125 | self.SetAppName("InVesalius 3") | 130 | self.SetAppName("InVesalius 3") |
@@ -142,26 +147,26 @@ def parse_comand_line(): | @@ -142,26 +147,26 @@ def parse_comand_line(): | ||
142 | parser.add_option("-i", "--import", action="store", dest="dicom_dir") | 147 | parser.add_option("-i", "--import", action="store", dest="dicom_dir") |
143 | 148 | ||
144 | options, args = parser.parse_args() | 149 | options, args = parser.parse_args() |
145 | - | 150 | + |
146 | session = Session() | 151 | session = Session() |
147 | - | 152 | + |
148 | if options.debug: | 153 | if options.debug: |
149 | # The user passed the debug option? | 154 | # The user passed the debug option? |
150 | # Yes! | 155 | # Yes! |
151 | # Then all pubsub message must be printed. | 156 | # Then all pubsub message must be printed. |
152 | ps.Publisher().subscribe(print_events, ps.ALL_TOPICS) | 157 | ps.Publisher().subscribe(print_events, ps.ALL_TOPICS) |
153 | - | 158 | + |
154 | session.debug = 1 | 159 | session.debug = 1 |
155 | - | 160 | + |
156 | if options.dicom_dir: | 161 | if options.dicom_dir: |
157 | # The user passed directory to me? | 162 | # The user passed directory to me? |
158 | import_dir = options.dicom_dir | 163 | import_dir = options.dicom_dir |
159 | ps.Publisher().sendMessage('Import directory', import_dir) | 164 | ps.Publisher().sendMessage('Import directory', import_dir) |
160 | return True | 165 | return True |
161 | - | 166 | + |
162 | # Check if there is a file path somewhere in what the user wrote | 167 | # Check if there is a file path somewhere in what the user wrote |
163 | else: | 168 | else: |
164 | - i = len(args) | 169 | + i = len(args) |
165 | while i: | 170 | while i: |
166 | i -= 1 | 171 | i -= 1 |
167 | file = args[i] | 172 | file = args[i] |
@@ -171,7 +176,7 @@ def parse_comand_line(): | @@ -171,7 +176,7 @@ def parse_comand_line(): | ||
171 | i = 0 | 176 | i = 0 |
172 | return True | 177 | return True |
173 | return False | 178 | return False |
174 | - | 179 | + |
175 | 180 | ||
176 | def print_events(data): | 181 | def print_events(data): |
177 | print data.topic | 182 | print data.topic |
@@ -183,18 +188,18 @@ def main(): | @@ -183,18 +188,18 @@ def main(): | ||
183 | application.MainLoop() | 188 | application.MainLoop() |
184 | 189 | ||
185 | if __name__ == '__main__': | 190 | if __name__ == '__main__': |
186 | - | 191 | + |
187 | # Needed in win 32 exe | 192 | # Needed in win 32 exe |
188 | if hasattr(sys,"frozen") and sys.frozen == "windows_exe": | 193 | if hasattr(sys,"frozen") and sys.frozen == "windows_exe": |
189 | multiprocessing.freeze_support() | 194 | multiprocessing.freeze_support() |
190 | - | 195 | + |
191 | # wxPython log | 196 | # wxPython log |
192 | #sys.stdout = open("stdout.log" ,"w") | 197 | #sys.stdout = open("stdout.log" ,"w") |
193 | sys.stderr = open("stderr.log", "w") | 198 | sys.stderr = open("stderr.log", "w") |
194 | - | 199 | + |
195 | # Add current directory to PYTHONPATH | 200 | # Add current directory to PYTHONPATH |
196 | sys.path.append(".") | 201 | sys.path.append(".") |
197 | - | 202 | + |
198 | # Init application | 203 | # Init application |
199 | main() | 204 | main() |
200 | - | 205 | + |