def checkUpdates(self, evt): #if we have internet and haven't yet checked for updates then do so if self._latestAvailableVersion not in [-1, None]:#we have a network connection but not yet tried an update #change IDLE routine so we won't come back here self.Unbind(wx.EVT_IDLE)#unbind all EVT_IDLE methods from app self.Bind(wx.EVT_IDLE, self.onIdle) #create updater (which will create dialogs as needed) self.updater=connections.Updater(app=self) self.updater.latest=self._latestAvailableVersion self.updater.suggestUpdate(confirmationDlg=False) evt.Skip()
def OnInit(self): self.version = psychopy.__version__ self.SetAppName('PsychoPy2') #show splash screen splash = PsychoSplashScreen() if splash: splash.Show() #LONG IMPORTS - these need to be imported after splash screen starts (they're slow) #but then that they end up being local so keep track in self splash.status.SetLabel(" Loading PsychoPy2..." + uidRootFlag) from psychopy.monitors import MonitorCenter from psychopy.app import coder, builder, wxIDs, connections, urls #set default paths and prefs self.prefs = preferences.Preferences() #from preferences.py if self.prefs.app['debugMode']: log.console.setLevel(log.DEBUG) self.keys = self.prefs.keys self.prefs.pageCurrent = 0 # track last-viewed page of prefs, to return there self.IDs = wxIDs self.urls = urls.urls self.quitting = False self.updater = None #create an updater when it's needed #setup links for URLs #on a mac, don't exit when the last frame is deleted, just show a menu if sys.platform == 'darwin': self.menuFrame = MenuFrame(parent=None, app=self) #get preferred view(s) from prefs and previous view if self.prefs.app['defaultView'] == 'last': mainFrame = self.prefs.appData['lastFrame'] else: # configobjValidate should take care of this situation (?), but doesn't: if self.prefs.app['defaultView'] in [ 'last', 'coder', 'builder', 'both' ]: mainFrame = self.prefs.app['defaultView'] else: self.prefs.app['defaultView'] = 'both' mainFrame = 'both' #fetch prev files if that's the preference if self.prefs.coder['reloadPrevFiles']: scripts = self.prefs.appData['coder']['prevFiles'] else: scripts = [] if self.prefs.builder['reloadPrevExp'] and ( 'prevFiles' in self.prefs.appData['builder'].keys()): exps = self.prefs.appData['builder']['prevFiles'] else: exps = [] #then override the prev files by command options and passed files if len(sys.argv) > 1: if sys.argv[1] == __name__: args = sys.argv[ 2:] # program was excecuted as "python.exe PsychoPyIDE.py %1' else: args = sys.argv[ 1:] # program was excecuted as "PsychoPyIDE.py %1' #choose which frame to start with if args[0] in ['builder', '--builder', '-b']: mainFrame = 'builder' args = args[1:] #can remove that argument elif args[0] in ['coder', '--coder', '-c']: mainFrame = 'coder' args = args[1:] #can remove that argument #did we get .py or .psyexp files? elif args[0][-7:] == '.psyexp': mainFrame = 'builder' exps = [args[0]] elif args[0][-3:] == '.py': mainFrame = 'coder' scripts = [args[0]] else: args = [] self.dpi = int(wx.GetDisplaySize()[0] / float(wx.GetDisplaySizeMM()[0]) * 25.4) if not (50 < self.dpi < 120): self.dpi = 80 #dpi was unreasonable, make one up #create both frame for coder/builder as necess self.coder = None self.builderFrames = [] self.copiedRoutine = None self.allFrames = [ ] #these are ordered and the order is updated with self.onNewTopWindow if mainFrame in ['both', 'coder']: self.showCoder(fileList=scripts) if mainFrame in ['both', 'builder']: self.showBuilder(fileList=exps) #send anonymous info to www.psychopy.org/usage.php #please don't disable this - it's important for PsychoPy's development if self.prefs.connections['allowUsageStats']: statsThread = threading.Thread( target=connections.sendUsageStats, args=(self.prefs.connections['proxy'], )) statsThread.start() if self.prefs.connections['checkForUpdates']: self.updater = connections.Updater( app=self, proxy=self.prefs.connections['proxy']) self.updater.suggestUpdate( confirmationDlg=False) #check for updates (silently) else: self.updater = False """This is in wx demo. Probably useful one day. #--------------------------------------------- def ShowTip(self): config = GetConfig() showTipText = config.Read("tips") if showTipText: showTip, index = eval(showTipText) else: showTip, index = (1, 0) if showTip: tp = wx.CreateFileTipProvider(opj("data/tips.txt"), index) ##tp = MyTP(0) showTip = wx.ShowTip(self, tp) index = tp.GetCurrentTip() config.Write("tips", str( (showTip, index) )) config.Flush()""" return True