def finish(self, text=None): """ This is a slot. It's called when a thread emits its "finished" Signal. The given text is posted to the status bar. @param text: Text for status bar @type text: str """ #print "in finish()" #logging.info("Finishing Progress Service") if self.progressRunning: with QMutexLocker(self.progressBarMutex): self.progressBar.hide() if self.throbberRunning: with QMutexLocker(self.throbberMutex): self.throbber.hide() if text is None: self.statusBarService.showMessage("Finished", 1000) else: self.statusBarService.showMessage( text, 3000) # show finish message for 3 seconds self.thread = None # release reference to thread
def update(self, value, min=None, max=None, text=None): """ Updates the progress bar with the given information. @param value: current value @type value: int @param min: Value that represents 0% @type min: int @param max: Value that represents 100% @type max: int @param text: Text to display on status bar @type text: str """ # self.progressRunning = True with QMutexLocker(self.progressBarMutex): if min and max: self.progressBar.setRange(min, max) self.progressBar.setValue(value) self.progressBar.show() if text is not None: self.statusBarService.showMessage(text)
def addPermanentWidget(self, widget): """ Places the given widget on the wrapped QStatusBar. """ with QMutexLocker(self.mutex): if self.statusbar: self.statusbar.addPermanentWidget(widget)
def append(self, text): """ Adding the text to the PlainTextEdit widget and setting the cursor, so that the text is visible. """ with QMutexLocker(self.mutex): self.appendPlainText(str(text)) self.moveCursor(QTextCursor.EndOfBlock) self.ensureCursorVisible()
def showMessage(self, msg, time=5000): """ Pass the given message on to the wrapped QStatusBar. Use a QMutex lock so that only one client of this service can write to the status bar at the same time. """ with QMutexLocker(self.mutex): if self.statusbar: self.statusbar.showMessage(msg, time)
def setProgressBarValue(self, value): """ Uses a QMutexLocker to set the minimum value for the progress bar. This also implicitely "starts" the progress, e.g. show the ProgressBar. """ self.progressRunning = True with QMutexLocker(self.progressBarMutex): self.progressBar.setValue(value) self.progressBar.show()
def start_progress(self, text=None): """ This is a slot. It starts the progress animation. The given text is posted to the status bar. @param text: Text for status bar @type text: str """ self.progressRunning = True with QMutexLocker(self.progressBarMutex): self.progressBar.show() if text is None: self.statusBarService.showMessage("Computing...", 1000) else: self.statusBarService.showMessage(text)
def start_throbber(self, text=None): """ This is a slot. It starts (the progress-state-less) throbber animation. The given text is posted to the status bar. @param text: Text for status bar @type text: str """ with QMutexLocker(self.throbberMutex): self.throbber.show() self.throbberRunning = True if text is None: self.statusBarService.showMessage("Computing...") else: self.statusBarService.showMessage(text)
def is_stopped(self): with QMutexLocker(self.mutex): return self.stopped
def stop(self): with QMutexLocker(self.mutex): self.stopped = True
def emit(self, record): with QMutexLocker(self.mutex): self.widget.append(self.formatter.format(record))
def setProgressBarMinimum(self, min): """ Uses a QMutexLocker to set the minimum value for the progress bar. """ with QMutexLocker(self.progressBarMutex): self.progressBar.setMinimum(min)