def loadModule(self, mod): try: Qt.QApplication.setOverrideCursor(Qt.QCursor(Qt.Qt.WaitCursor)) self.manager.loadModule(mod) self.showMessage("Loaded module '%s'." % mod, 10000) finally: Qt.QApplication.restoreOverrideCursor()
def scanPointClicked(self, plotItem, points): try: point = points[0] Qt.QApplication.setOverrideCursor(Qt.QCursor(Qt.Qt.WaitCursor)) #print "clicked:", point.data() plot = self.getElement("Data Plot") plot.clear() self.selectedSpot = point self.selectedScan = plotItem.scan fh = self.dataModel.getClampFile(point.data()) self.detector.loadFileRequested(fh) #self.dbCtrl.scanSpotClicked(fh) finally: Qt.QApplication.restoreOverrideCursor()
def loadFile(self, files): try: Qt.QApplication.setOverrideCursor(Qt.QCursor(Qt.Qt.WaitCursor)) for fh in files: if self.host is None: self.sigFileLoaded.emit(fh) self.loaded.append(fh) elif self.host.loadFileRequested([fh]): name = fh.name(relativeTo=self.ui.dirTree.baseDirHandle()) item = Qt.QTreeWidgetItem([name]) item.file = fh self.ui.fileTree.addTopLevelItem(item) self.sigFileLoaded.emit(fh) self.loaded.append(fh) finally: Qt.QApplication.restoreOverrideCursor()
def itemExpandedEvent(self, item): """Called whenever an item in the tree is expanded; responsible for loading children if they have not been loaded yet.""" if not item.childrenLoaded: try: Qt.QApplication.setOverrideCursor(Qt.QCursor(Qt.Qt.WaitCursor)) ## Display loading message before starting load loading = None if item.handle.isDir(): loading = Qt.QTreeWidgetItem(['loading..']) item.addChild(loading) Qt.QApplication.instance().processEvents( ) ## make sure the 'loading' item is displayed before building the tree if loading is not None: item.removeChild(loading) ## now load all children self.rebuildChildren(item) item.childrenLoaded = True finally: Qt.QApplication.restoreOverrideCursor() item.expanded() self.scrollToItem(item.child(item.childCount() - 1)) self.scrollToItem(item)
def loadTask(self, handle): prof = Profiler('TaskRunner.loadTask', disabled=True) try: Qt.QApplication.setOverrideCursor(Qt.QCursor(Qt.Qt.WaitCursor)) self.stopSequence() self.stopSingle() prof.mark('stopped') fn = handle.name() ## Remove all docks self.clearDocks() prof.mark('cleared') ## Create task object from requested file prot = Task(self, fileName=fn) ## Set current task self.currentTask = prot prof.mark('made task') #print "Docks cleared." ## Update task parameters self.protoStateGroup.setState(prot.conf['conf']) prof.mark('set state') ## update dev list self.updateDeviceList() prof.mark('update dev list') ## Update sequence parameters, dis/enable sequence dock ## Create new docks self.updateDeviceDocks() prof.mark('update docks') ## Configure docks for d in prot.devices: if d in self.docks: try: self.docks[d].widget().restoreState(prot.devices[d]) prof.mark('configured dock: ' + d) except: printExc("Error while loading task dock:") ## create and configure analysis docks if 'analysis' in prot.conf: for k in prot.conf['analysis']: try: self.createAnalysisDock(k) conf = prot.conf['analysis'][k] self.analysisDocks[k].widget().restoreState(conf) prof.mark('configured dock: ' + k) except: printExc("Error while loading analysis dock:") ## Load sequence parameter state (must be done after docks have loaded) self.ui.sequenceParamList.loadState(prot.conf['params']) self.updateSeqParams('protocol') prof.mark('load seq params') ## Configure dock positions winState = prot.conf['windowState'] if winState is not None: self.win.restoreState(winState) prof.mark('position docks') finally: Qt.QApplication.restoreOverrideCursor() prof.finish()
def redisplayData(self, points): ## data must be [(scan, fh, <event time>), ...] #raise Exception('blah') #print points try: Qt.QApplication.setOverrideCursor(Qt.QCursor(Qt.Qt.WaitCursor)) plot = self.getElement("Data Plot") plot.clear() eTable = self.getElement("Event Table") sTable = self.getElement("Stats") #num = len(point.data) num = len(points) statList = [] evList = [] for i in range(num): color = pg.intColor(i, num) #scan, fh = point.data[i] try: scan, fh = points[i][:2] except: print(points[i]) raise if len(points[i]) == 3: evTime = points[i][2] else: evTime = None scan.displayData(fh, plot, color, evTime) ## show stats stats = scan.getStats(fh.parent()) statList.append(stats) events = scan.getEvents(fh)['events'] if len(events) > 0: evList.append(events) sTable.setData(statList) if len(evList) > 0: try: eTable.setData(np.concatenate(evList)) except: for i in range(1, len(evList)): if len(evList[i].dtype) != len(evList[i - 1].dtype): print( "Cannot concatenate; event lists have different dtypes:" ) print(evList[i].dtype) print(evList[i - 1].dtype) else: for j in range(len(evList[i].dtype)): if evList[i - 1].dtype[j] != evList[i].dtype[j]: for l in evList: print(l) print( "Warning: can not concatenate--field '%s' has inconsistent types %s, %s (data printed above)" % (evList[i].dtype.names[j], str(evList[i - 1].dtype[j]), str(evList[i].dtype[j]))) raise finally: Qt.QApplication.restoreOverrideCursor()