def select_wav_file(self): ''' Allows the user to select a file and laods info about it ''' file = select_file(self, ['wav', 'flac']) if file is not None: self.__clear() self.file.setText(file) import soundfile as sf self.__info = sf.info(file) self.channelSelector.clear() for i in range(0, self.__info.channels): self.channelSelector.addItem(f"{i + 1}") self.channelSelector.setEnabled(self.__info.channels > 1) self.startTime.setTime(QtCore.QTime(0, 0, 0)) self.startTime.setEnabled(True) self.__duration = math.floor(self.__info.duration * 1000) max_time = QtCore.QTime(0, 0, 0).addMSecs(self.__duration) self.endTime.setMaximumTime(max_time) self.endTime.setTime(max_time) self.endTime.setEnabled(True) self.maxTime.setMaximumTime(max_time) self.maxTime.setTime(max_time) self.loadButton.setEnabled(True) self.updateChart.setEnabled(True) else: self.__signal = None
def updateTimers(self): self.ui.wallClock.setText( QtCore.QTime.currentTime().toString('HH:mm:ss')) if self.presentationStarted: self.ui.slideClock.setText( QtCore.QTime(0, 0).addMSecs( self.slideClock.elapsed()).toString('mm:ss')) self.ui.presentationClock.setText( 'Total\n' + QtCore.QTime(0, 0).addMSecs( self.presentationClock.elapsed()).toString('HH:mm:ss'))
def assignCor(): self.timestamp = QtCore.QTime() self.save_runtime = '' self._cw = CorrelationMainWindow() self._cw.start_counter_Action.triggered.connect(self.start_corr) self._cw.pause_counter_Action.triggered.connect( self.pause_resume_corr) self._cw.pause_counter_Action.setEnabled(False) self._cw.save_Action.triggered.connect(self.save_corr) self._cpw = self._cw.correlation_hist_PlotWidget self._cpw.setLabel('left', 'g<sup>(2)</sup>(<font>τ</font>)') self._cpw.setLabel('bottom', '<font>τ</font>', units='s') self.c_curves = [] # Create an empty plot curve to be filled later, set its pen self.c_curves.append( pg.PlotDataItem(pen=pg.mkPen(palette.c3, style=QtCore.Qt.DotLine), symbol='o', symbolPen=palette.c3, symbolBrush=palette.c3, symbolSize=5)) self._cpw.addItem(self.c_curves[-1]) self.c_curves.append( pg.PlotDataItem(pen=pg.mkPen(palette.c4, width=3), symbol=None)) self._cpw.addItem(self.c_curves[-1]) # setting the x axis length correctly self._cpw.setXRange( -self._cw.bin_width_DoubleSpinBox.value() * self._cw.no_of_bins_SpinBox.value() / 1e9 / 2, self._cw.bin_width_DoubleSpinBox.value() * self._cw.no_of_bins_SpinBox.value() / 1e9 / 2)
def on_file_finished(self): # update status bar self.nFiles_done = self.nFiles_done + 1 self.status_update.emit("Processing {}: ({} of {})".format( self.shortname, self.nFiles_done, self.nFiles)) # update progress bar self.progressUp.emit() # update the countdown timer with estimate of remaining time avgTimePerFile = int(self.timer.elapsed() / self.nFiles_done) filesToGo = self.nFiles - self.nFiles_done + 1 remainingTime = filesToGo * avgTimePerFile timeAsString = QtCore.QTime(0, 0).addMSecs(remainingTime).toString() self.clockUpdate.emit(timeAsString)
def compare_signals(self): ''' Loads the selected signals into the spectrum chart. ''' left_signal = self.__get_signal_data(self.leftSignal.currentText()) right_signal = self.__get_signal_data(self.rightSignal.currentText()) max_duration = math.floor( max(left_signal.duration_seconds, right_signal.duration_seconds) * 1000) self.startTime.setTime(QtCore.QTime(0, 0, 0)) self.startTime.setEnabled(True) max_time = QtCore.QTime(0, 0, 0).addMSecs(max_duration) self.endTime.setMaximumTime(max_time) self.endTime.setTime(max_time) self.endTime.setEnabled(True) self.maxTime.setMaximumTime(max_time) self.maxTime.setTime(max_time) self.__init_resolution_selector(left_signal.signal) self.__spectrum_analyser.left = left_signal.filter_signal( filt=self.filterLeft.isChecked()) self.__spectrum_analyser.right = right_signal.filter_signal( filt=self.filterRight.isChecked()) self.__spectrum_analyser.analyse() self.updateChart.setEnabled(True)
def makeWidget(self): opts = self.param.opts w = QTimeCustom(QtCore.QTime(QtCore.QTime.currentTime())) if 'minutes_increment' in opts: w.setMinuteIncrement(opts['minutes_increment']) if 'format' not in opts: opts['format'] = 'hh:mm' w.setDisplayFormat(opts['format']) w.sigChanged = w.timeChanged w.value = w.time w.setValue = w.setTime return w
def __init__(self, display): Tool.__init__(self, display) self.paths = [] # min time difference to add a line to qpainterpath # when drawing in [ms]: self.MIN_DT = 25 self._timer = QtCore.QTime() self.pa = self.setParameterMenu() self.pa.sigChildRemoved.connect(self._removePath) pNew = self.pa.addChild({ 'name': 'New', 'type': 'action', 'value': True }) pNew.sigActivated.connect(self._newCurve) pNew.sigActivated.connect(self._menu.hide)
def __init__(self, display): Tool.__init__(self, display) self.paths = [] # min time difference to add a line to qpainterpath # when drawing in [ms]: self.MIN_DT = 25 self._timer = QtCore.QTime() self.pa = self.setParameterMenu() self.pa.sigChildRemoved.connect(self._removePath) self.pType = self.pa.addChild({ 'name': 'Type', 'type': 'list', 'value': 'Freehand', 'limits': list(ITEMS.values())}) self.pNew = self.pa.addChild({ 'name': 'New', 'type': 'action', 'value': True}) self.pNew.sigActivated.connect(self.new) self.pNew.sigActivated.connect(self._menu.resizeToContent) pMask = self.pa.addChild({ 'name': 'Create Mask', 'type': 'action'}) pMask.sigActivated.connect(self._createMaskFromSelection) pArea = self.pa.addChild({ 'name': 'Measure areas', 'type': 'action'}) pArea.sigActivated.connect(self._measurePath) self.pMask = pArea.addChild({ 'name': 'Relative to selection', 'type': 'list', 'value': '-', 'limits': ['-']}) list(self.pMask.items.keys())[0].widget.showPopup = self._updatePMask
def initUI(self): layout = QtWidgets.QStackedLayout() self.iterations = 0 #Background area test self.background = QtWidgets.QLabel(self) self.background.show() #Setup text area for clock newfont = QtGui.QFont("Consolas", 120, QtGui.QFont.Bold) self.lbl1 = QtWidgets.QLabel() self.lbl1.setAlignment(QtCore.Qt.AlignCenter) self.lbl1.setFont(newfont) self.lbl1.setWindowFlags(QtCore.Qt.FramelessWindowHint) #add window title self.setWindowTitle("onTheFly Time Elapsed") #Timer to refresh connection self.timer = QtCore.QTimer(self) #timer.timeout.connect(self.showTime) self.timer.timeout.connect(self.updates) self.timer.start(1000) #update every 1s #Start QTime self.t = QtCore.QTime() self.t.start() #run first update self.updates() #layout area for widgets layout.addWidget(self.background) layout.addWidget(self.lbl1) layout.setCurrentIndex(1) self.setLayout(layout) self.setGeometry(300, 300, 250, 150) self.show()
def work(self): if self.E.is_compressed(): self.status_update.emit("Decompressing {}".format(self.E.basename)) self.E.decompress() if not self.E.ready_to_process: if not self.E.has_lls_tiffs: self._logger.warning("No TIFF files to process in {}".format( self.path)) if not self.E.parameters.isReady(): self._logger.warning("Incomplete parameters for: {}".format( self.path)) self.skipped.emit(self.path) return # this needs to go here instead of __init__ in case folder is compressed try: self.P = self.E.localParams(**self.opts) except Exception: self.error.emit() self.finished.emit() raise # we process one folder at a time. Progress bar updates per Z stack # so the maximum is the total number of timepoints * channels self.nFiles = len(self.P.tRange) * len(self.P.cRange) self._logger.info("#" * 50) self._logger.info("Processing {}".format(self.E.basename)) self._logger.info("#" * 50 + "\n") self._logger.debug("Full path {}".format(self.path)) self._logger.debug("Parameters {}\n".format(self.E.parameters)) if self.P.correctFlash: try: self.status_update.emit( "Correcting Flash artifact on {}".format(self.E.basename)) self.E.path = self.E.correct_flash(**self.P) except mosaicpy.llsdir.MOSAICpyError: self.error.emit() raise # if not flash correcting but there is trimming/median filter requested elif self.P.medianFilter or any( [any(i) for i in (self.P.trimX, self.P.trimY, self.P.trimZ)]): self.E.path = self.E.median_and_trim(**self.P) self.nFiles_done = 0 self.progressValue.emit(0) self.progressMaxVal.emit(self.nFiles) self.status_update.emit("Processing {}: (0 of {})".format( self.E.basename, self.nFiles)) # only call cudaDeconv if we need to deskew or deconvolve if self.P.nIters > 0 or (self.P.deskew > 0 and self.P.saveDeskewedRaw): try: # check the binary path and create object binary = mosaicpy.cudabinwrapper.CUDAbin(_CUDABIN) except Exception: self.error.emit() raise self.__argQueue = divide_arg_queue(self.E, len(self.GPU_SET), binary) # with the argQueue populated, we can now start the workers if not len(self.__argQueue): self._logger.error( "No channel arguments to process in LLSitem: %s" % self.shortname) self._logger.debug("LLSitemWorker FINISH: {}".format( self.E.basename)) self.finished.emit() return self.startCUDAWorkers() else: self.post_process() self.timer = QtCore.QTime() self.timer.restart()
def updateClock(self): self._eta -= 1000 if self._eta > 0: _d = QtCore.QTime(0, 0).addMSecs(self._eta).toString() self.clock.display(_d)
def _interpretValue(self, v): return QtCore.QTime(v)
"QPushButton": QtWidgets.QPushButton(), }, "PyQt_pickable": { "QByteArray": QtCore.QByteArray(bytes(range(256))), "QColor": QtGui.QColor(10, 20, 30, 40), ## "QChar": # n'a plus l'air d'exister dans PyQt5 "QDate": QtCore.QDate(2020, 10, 31), "QDateTime": QtCore.QDateTime(2020, 10, 31, 20, 30), "QKeySequence": QtGui.QKeySequence(), ## "QLatin1Char": # n'a plus l'air d'exister dans PyQt5 ## "QLatin1String"# n'a plus l'air d'exister dans PyQt5 "QLine": QtCore.QLine(QtCore.QPoint(0, 1), QtCore.QPoint(2, 3)), "QLineF": QtCore.QLineF(QtCore.QPoint(0.0, 1.1), QtCore.QPoint(2.2, 3.3)), "QPen": QtGui.QPen(), "QBrush": QtGui.QBrush(), "QPoint": QtCore.QPoint(0, 1), "QPointF": QtCore.QPointF(0.0, 1.1), "QPolygon": QtGui.QPolygon([QtCore.QPoint(0, 1), QtCore.QPoint(2, 3)]), "QPolygonF": QtGui.QPolygonF([QtCore.QPoint(0.0, 1.1), QtCore.QPoint(2.2, 3.3)]), "QRect": QtCore.QRect(QtCore.QPoint(0, 1), QtCore.QPoint(2, 3)), "QRectF": QtCore.QRectF(QtCore.QPoint(0.0, 1.1), QtCore.QPoint(2.2, 3.3)), "QSize": QtCore.QSize(10, 20), "QSizeF": QtCore.QSizeF(10.5, 20.5), ## "QMatrix": # Support for the deprecated QMatrix class has been removed ## "QString": # n'a plus l'air d'exister dans PyQt5 "QTime": QtCore.QTime(20, 30), "QTransform": QtGui.QTransform(), # pas reducable dans documentation ? "QVector3D": QtGui.QVector3D(), # pas reducable dans documentation ? }, }