def Startup(self): # Importing takes sometime, therefore it will be done # while splash is being shown from invesalius.gui.frame import Frame from invesalius.control import Controller from invesalius.project import Project self.main = Frame(None) self.control = Controller(self.main) self.fc = wx.FutureCall(1, self.ShowMain) wx.FutureCall(1, parse_comand_line) # Check for updates from threading import Thread p = Thread(target=utils.UpdateCheck, args=()) p.start()
class Inv3SplashScreen(SplashScreen): """ Splash screen to be shown in InVesalius initialization. """ def __init__(self): # Splash screen image will depend on currently language lang = False self.locale = wx.Locale(wx.LANGUAGE_DEFAULT) # Language information is available in session configuration # file. First we need to check if this file exist, if now, it # should be created create_session = False session = ses.Session() if not (session.ReadSession()): create_session = True install_lang = 0 lang = session.GetLanguage() if lang: if (lang != "False"): _ = i18n.InstallLanguage(lang) install_lang = 1 else: install_lang = 0 else: install_lang = 0 # If no language is set into session file, show dialog so # user can select language if install_lang == 0: dialog = lang_dlg.LanguageDialog() # FIXME: This works ok in linux2, darwin and win32, # except on win64, due to wxWidgets bug try: ok = (dialog.ShowModal() == wx.ID_OK) except wx._core.PyAssertionError: ok = True finally: if ok: lang = dialog.GetSelectedLanguage() session.SetLanguage(lang) _ = i18n.InstallLanguage(lang) else: homedir = self.homedir = os.path.expanduser('~') invdir = os.path.join(homedir, ".invesalius") shutil.rmtree(invdir) sys.exit() dialog.Destroy() # Session file should be created... So we set the recent # choosen language if (create_session): session.CreateItens() session.SetLanguage(lang) session.WriteSessionFile() # session.SaveConfigFileBackup() # Only after language was defined, splash screen will be # shown if lang: #import locale #try: # locale.setlocale(locale.LC_ALL, '') #except locale.Error: # pass # For pt_BR, splash_pt.png should be used if (lang.startswith('pt')): icon_file = "splash_pt.png" else: icon_file = "splash_" + lang + ".png" if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\ or sys.frozen == "console_exe"): abs_file_path = os.path.abspath(".." + os.sep) path = abs_file_path path = os.path.join(path, 'icons', icon_file) else: path = os.path.join(".","icons", icon_file) if not os.path.exists(path): path = os.path.join(".", "icons", "splash_en.png") bmp = wx.Image(path).ConvertToBitmap() try: style = wx.adv.SPLASH_TIMEOUT | wx.adv.SPLASH_CENTRE_ON_SCREEN except AttributeError: style = wx.SPLASH_TIMEOUT | wx.SPLASH_CENTRE_ON_SCREEN SplashScreen.__init__(self, bitmap=bmp, splashStyle=style, milliseconds=1500, id=-1, parent=None) self.Bind(wx.EVT_CLOSE, self.OnClose) wx.Yield() wx.CallLater(200, self.Startup) def Startup(self): # Importing takes sometime, therefore it will be done # while splash is being shown from invesalius.gui.frame import Frame from invesalius.control import Controller from invesalius.project import Project self.main = Frame(None) self.control = Controller(self.main) self.fc = wx.CallLater(200, self.ShowMain) options, args = parse_comand_line() wx.CallLater(1, use_cmd_optargs, options, args) # Check for updates from threading import Thread p = Thread(target=utils.UpdateCheck, args=()) p.start() def OnClose(self, evt): # Make sure the default handler runs too so this window gets # destroyed evt.Skip() self.Hide() # If the timer is still running then go ahead and show the # main frame now if self.fc.IsRunning(): self.fc.Stop() self.ShowMain() def ShowMain(self): # Show main frame self.main.Show() if self.fc.IsRunning(): self.Raise()