Commit 198def5c9858c79936e5994c03af84975d2750e2

Authored by Paulo Henrique Junqueira Amorim
1 parent eed9bb86

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