def __init__(self, name: str): self._filepath: Optional[str] = None super().__init__(name) self.groupname = 'data' # type: ignore[misc] self.nLoadedRecords = 0 self.loadingThread = QtCore.QThread() self.loadingWorker = _Loader(self.filepath, self.groupname) self.loadingWorker.moveToThread(self.loadingThread) self.loadingThread.started.connect(self.loadingWorker.loadData) self.loadingWorker.dataLoaded.connect(self.onThreadComplete) self.loadingWorker.dataLoaded.connect( lambda x: self.loadingThread.quit()) self.setProcessOptions.connect(self.loadingWorker.setPathAndGroup)
def main(dataSrc): plottrlog.LEVEL = logging.INFO app = QtWidgets.QApplication([]) fc, win = autoplot(plotWidgetClass=plotWidgetClass) dataThread = QtCore.QThread() dataSrc.moveToThread(dataThread) dataSrc.dataready.connect( lambda d: win.setInput(data=d, resetDefaults=False)) dataSrc.nomoredata.connect(dataThread.quit) dataThread.started.connect(dataSrc.gimmesomedata) win.windowClosed.connect(dataThread.quit) dataThread.start() if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): QtWidgets.QApplication.instance().exec_()
def __init__(self, parent: Optional[QtWidgets.QWidget] = None, dbPath: Optional[str] = None): """Constructor for :class:`QCodesDBInspector`.""" super().__init__(parent) self._plotWindows: Dict[int, WindowDict] = {} self.filepath = dbPath self.dbdf = None self.monitor = QtCore.QTimer() # flag for determining what has been loaded so far. # * None: nothing opened yet. # * -1: empty DS open. # * any value > 0: run ID from the most recent loading. self.latestRunId = None self.setWindowTitle('Plottr | QCoDeS dataset inspectr') ### GUI elements # Main Selection widgets self.dateList = DateList() self._selected_dates: Tuple[str, ...] = () self.runList = RunList() self.runInfo = RunInfo() rightSplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical) rightSplitter.addWidget(self.runList) rightSplitter.addWidget(self.runInfo) rightSplitter.setSizes([400, 200]) splitter = QtWidgets.QSplitter() splitter.addWidget(self.dateList) splitter.addWidget(rightSplitter) splitter.setSizes([100, 500]) self.setCentralWidget(splitter) # status bar self.status = QtWidgets.QStatusBar() self.setStatusBar(self.status) # toolbar self.toolbar = self.addToolBar('Data monitoring') # toolbar item: monitor interval self.monitorInput = MonitorIntervalInput() self.monitorInput.setToolTip('Set to 0 for disabling') self.monitorInput.intervalChanged.connect(self.setMonitorInterval) self.toolbar.addWidget(self.monitorInput) self.toolbar.addSeparator() # toolbar item: auto-launch plotting self.autoLaunchPlots = FormLayoutWrapper([('Auto-plot new', QtWidgets.QCheckBox())]) tt = "If checked, and automatic refresh is running, " tt += " launch plotting window for new datasets automatically." self.autoLaunchPlots.setToolTip(tt) self.toolbar.addWidget(self.autoLaunchPlots) # menu bar menu = self.menuBar() fileMenu = menu.addMenu('&File') # action: load db file loadAction = QtWidgets.QAction('&Load', self) loadAction.setShortcut('Ctrl+L') loadAction.triggered.connect(self.loadDB) fileMenu.addAction(loadAction) # action: updates from the db file refreshAction = QtWidgets.QAction('&Refresh', self) refreshAction.setShortcut('R') refreshAction.triggered.connect(self.refreshDB) fileMenu.addAction(refreshAction) # sizing scaledSize = 640 * rint(self.logicalDpiX() / 96.0) self.resize(scaledSize, scaledSize) ### Thread workers # DB loading. can be slow, so nice to have in a thread. self.loadDBProcess = LoadDBProcess() self.loadDBThread = QtCore.QThread() self.loadDBProcess.moveToThread(self.loadDBThread) self.loadDBProcess.pathSet.connect(self.loadDBThread.start) self.loadDBProcess.dbdfLoaded.connect(self.DBLoaded) self.loadDBProcess.dbdfLoaded.connect(self.loadDBThread.quit) self.loadDBThread.started.connect( self.loadDBProcess.loadDB) # type: ignore[attr-defined] ### connect signals/slots self.dbdfUpdated.connect(self.updateDates) self.dbdfUpdated.connect(self.showDBPath) self.dateList.datesSelected.connect(self.setDateSelection) self.dateList.fileDropped.connect(self.loadFullDB) self.runList.runSelected.connect(self.setRunSelection) self.runList.runActivated.connect(self.plotRun) self._sendInfo.connect(self.runInfo.setInfo) self.monitor.timeout.connect(self.monitorTriggered) if self.filepath is not None: self.loadFullDB(self.filepath)