def __init__(self, parent=None, statusBarService=None): """ Creates a QProgressBar and adds it to the given status bar (for threads that can provide accurate progress information). Note: The status bar can either be a QStatusBar or the StatusBarService. In the default BioPARKIN use, it is the StatusBarService instance. @todo: A throbber is created and also added to the status bar (for threads that can only provide start/stop information). """ # super(ProgressBarService, self).__init__(parent) # done in __new__ if statusBarService is not None: self.statusBarService = statusBarService self.progressBar = QProgressBar(None) # used for showing progress self.progressBarMutex = QMutex() self.progressBar.hide() self.statusBarService.addPermanentWidget(self.progressBar) self.progressRunning = False self.throbber = QLabel() self.throbberRunning = False self.throbberMutex = QMutex() self.statusBarService.addPermanentWidget(self.throbber) self.throbber.show() self.throbber.hide() throbberImage = QMovie(":/images/Spinning_wheel_throbber.gif", parent=self.throbber) throbberImage.setScaledSize(QSize(24, 24)) throbberImage.setCacheMode(QMovie.CacheAll) throbberImage.start() self.throbber.setMovie(throbberImage) self.throbber.setFixedSize(24, 24)
def __init__(self, parent=None): super(StatusArea, self).__init__(parent) self.setStyleSheet('StatusArea {background: yellow}') self.msg = QLabel(self) self.file = QLabel(self) self.progress = QProgressBar(self) self.msg.setFont(View.labelsFont()) self.file.setFont(View.editsFont()) self.progress.setMaximum(100) self.progress.setMinimum(0) self.progress.setTextVisible(False) self.progress.setStyleSheet(""" QProgressBar { border: 2px solid grey; border-radius: 5px; width: 60px; height: 10px; } QProgressBar::chunk { background-color: #05B8CC; width: 5px; }""") layout = QHBoxLayout() layout.addWidget(self.msg, 0, Qt.AlignLeft) layout.addWidget(self.file, 0, Qt.AlignLeft) layout.addWidget(self.progress, 0, Qt.AlignRight) self.setLayout(layout)
def _init_statusbar(self): self._progressbar = QProgressBar() self._progressbar.setMinimum(0) self._progressbar.setMaximum(100) self._progressbar.hide() self.statusBar().addPermanentWidget(self._progressbar)
def __init__(self): """ Constructo FUnction """ QMainWindow.__init__(self) self.setWindowTitle("Application Title Here") self.setGeometry(300, 250, 400, 300) self.statusLabel = QLabel('Showing Progress') self.progressBar = QProgressBar() self.progressBar.setMinimum(0) self.progressBar.setMaximum(1000000)
def _create_control(self, parent): layout = QVBoxLayout() pb = QProgressBar() self._message_control = QLabel() self._message_control.setText(' ') layout.addWidget(self._message_control) layout.addWidget(pb) return pb
def setupStatusBar(self): """Ajoute une barre de status""" self.progressBar = QProgressBar() self.statusLabel = QLabel('Progression ...') self.progressBar.setMaximum(100) self.progressBar.setMinimum(0) self.statusBar = QStatusBar() # # Affiche un message durant 2 sec après ouverture de l'application # self.statusBar.showMessage('Please Wait ...', 2000) self.progressBar.setValue(10) self.statusBar.addWidget(self.statusLabel, 1) self.statusBar.addWidget(self.progressBar, 2) self.setStatusBar(self.statusBar)
def showProgressbar(self): if self.progressText: if not self.pb_widget: self.pb_widget = QDialog(self.parent()) self.pb_widget.setWindowFlags(Qt.SplashScreen) self.pb_widget.setModal(True) hl = QHBoxLayout() pb = QProgressBar() pb.setRange(0, 0) hl.addWidget(pb) hl.addWidget(QLabel(self.progressText)) self.pb_widget.setLayout(hl) self.pb_widget.show()
def modSB(self): if self.PPbar is None: self.PPbar = True self.statusb.clear() self.pbar = QProgressBar() self.pbar.setMaximum(100) self.pbar.setMinimum(0) self.plabel = QLabel() self.statusb.addWidget(self.plabel, 0.5) self.statusb.addWidget(self.pbar, 3) else: self.PPbar = None self.statusb.removeWidget(self.plabel) self.statusb.removeWidget(self.pbar) self.statusb.clear()
def createRotableGroupBox(self): self.rotableGroupBox = QGroupBox("Rotable Widgets") self.rotableWidgets.append(QSpinBox()) self.rotableWidgets.append(QSlider()) self.rotableWidgets.append(QDial()) self.rotableWidgets.append(QProgressBar()) count = len(self.rotableWidgets) for i in range(count): self.rotableWidgets[i].valueChanged[int].\ connect(self.rotableWidgets[(i+1) % count].setValue) self.rotableLayout = QGridLayout() self.rotableGroupBox.setLayout(self.rotableLayout) self.rotateWidgets()
def __init__(self, parent, message): super(ExportProgressDialog, self).__init__(parent) self.setModal(True) self.setWindowTitle(message) indicator = QProgressBar() indicator.setMinimum(0) indicator.setMaximum(0) messageLabel = QLabel(message) layout = QGridLayout() layout.addWidget(messageLabel) layout.addWidget(indicator) self.setLayout(layout)
def initInterface(self, kwargs): layout = QGridLayout() self._data_table = SearchTable(name=kwargs.get("name")) self._progress_spider = QProgressBar() self._label_count = QLabel(self.tr("0 items scraped")) # make it a busy indicator. you don't know when it'll finish self._progress_spider.setMinimum(0); self._progress_spider.setMaximum(0) self._progress_spider.setTextVisible(False) self._btn_stop_spider = QPushButton(self.tr("Stop Spider")) self._btn_stop_spider.clicked.connect(self.stop_spider) row = 0; col = 0; layout.addWidget(self._data_table, row, col, 1, 4) row += 1; layout.addWidget(self._progress_spider, row, col, 1, 1) col += 1 layout.addWidget(self._label_count, row, col, 1, 2) col += 2 layout.addWidget(self._btn_stop_spider, row, col, 1, 1) self.setLayout(layout)
def showProgressbar(self): if self.progressText: # generate widget if not given in init if not self.pb_widget: self.pb_widget = QDialog(self.parent()) self.pb_widget.setWindowFlags(Qt.SplashScreen) self.pb_widget.setModal(True) # add button delete_button = QPushButton('X') delete_button.clicked.connect(self.exit) hl = QHBoxLayout() pb = QProgressBar() pb.setRange(0, 0) hl.addWidget(pb) hl.addWidget(QLabel(self.progressText)) if self.abortButton: hl.addWidget(delete_button) self.pb_widget.setLayout(hl) self.pb_widget.show()
def __init__(self): QMainWindow.__init__(self) # the user interface, consisting of a progress bar above a plain # text edit, which logs all actions. container = QWidget(self) container.setLayout(QVBoxLayout(container)) self.setCentralWidget(container) progressbar = QProgressBar(container) container.layout().addWidget(progressbar) log = QPlainTextEdit(container) container.layout().addWidget(log) # the actual worker thread counter = Counter(100, self) # an action to quit the windows exit = QAction(QIcon.fromTheme('application-exit'), 'exit', self) # add two actions to start and stop the worker to the toolbar of the # main window start_counting = QAction(QIcon.fromTheme('media-playback-start'), 'Start counting', self) stop_counting = QAction(QIcon.fromTheme('media-playback-stop'), 'Stop counting', self) # initially no counter runs, so we can disable the stop action stop_counting.setEnabled(False) # add all actions to a toolbar actions = self.addToolBar('Actions') actions.addAction(exit) actions.addSeparator() actions.addAction(start_counting) actions.addAction(stop_counting) # quit the application, if the quit action is triggered exit.triggered.connect(QApplication.instance().quit) # start and stop the counter, if the corresponding actions are # triggered. start_counting.triggered.connect(counter.start) stop_counting.triggered.connect(counter.stop) # adjust the minimum and the maximum of the progress bar, if # necessary. Not really required in this snippet, but added for the # purpose of demonstrating it counter.minimumChanged.connect(progressbar.setMinimum) counter.maximumChanged.connect(progressbar.setMaximum) # switch the enabled states of the actions according to whether the # worker is running or not counter.started.connect(partial(start_counting.setEnabled, False)) counter.started.connect(partial(stop_counting.setEnabled, True)) counter.finished.connect(partial(start_counting.setEnabled, True)) counter.finished.connect(partial(stop_counting.setEnabled, False)) # update the progess bar continuously counter.progress.connect(progressbar.setValue) # log all actions in our logging widget counter.started.connect( partial(self.statusBar().showMessage, 'Counting')) counter.finished.connect(partial(self.statusBar().showMessage, 'Done')) # log a forced stop stop_counting.triggered.connect(partial(log.appendPlainText, 'Stopped')) # log all counted values counter.progress.connect(lambda v: log.appendPlainText(str(v))) # and finally show the current state in the status bar. counter.started.connect(partial(log.appendPlainText, 'Counting')) counter.finished.connect(partial(log.appendPlainText, 'Done'))