class ProgressDialog(QDialog): def __init__(self, parent): QDialog.__init__(self, parent) self.resize(300, 75) self.setWindowTitle("Updating") self.vw = QWidget(self) self.vl = QVBoxLayout(self.vw) self.vl.setMargin(10) self.label = QLabel(self.vw) self.label.setText("<b>Downloading:</b> library.zip") self.vl.addWidget(self.label) self.horizontalLayoutWidget = QWidget() self.horizontalLayout = QHBoxLayout(self.horizontalLayoutWidget) self.horizontalLayout.setMargin(0) self.progressbar = QProgressBar(self.horizontalLayoutWidget) self.progressbar.setFixedWidth(260) self.progressbar.setMinimum(0) self.progressbar.setMaximum(100) self.stopButton = QPushButton(self.horizontalLayoutWidget) self.stopButton.setFlat(True) self.stopButton.setIcon(Icons.stop) self.stopButton.setFixedSize(16,16) self.horizontalLayout.addWidget(self.progressbar) self.horizontalLayout.addWidget(self.stopButton) self.vl.addWidget(self.horizontalLayoutWidget) self.stopButton.clicked.connect(self.forceStop) def setValue(self,val): self.progressbar.setValue(val) def forceStop(self): self.emit(SIGNAL("forceStop"))
def initUI(self): self.setWindowTitle(APPNAME) file_menu = self.menuBar().addMenu('File') new_proj_action = create_action(self, 'New Project', self.new_project) open_proj_action = create_action(self, 'Open Project', self.open_project) import_orosMat_action = create_action(self, 'Import Oros Mat', self.import_orosMat) quit_action = create_action(self, 'Quit', self.quit) add_actions(file_menu, (new_proj_action, open_proj_action, None, import_orosMat_action, None, quit_action)) progress_bar = QProgressBar(self) progress_bar.setFixedWidth(200) progress_bar.setTextVisible(False) progress_bar.setVisible(False) self.progress_bar = progress_bar self.statusBar().addPermanentWidget(progress_bar) self.toolBar = self.addToolBar('Curves') main_widget = QWidget(self) main_layout = QGridLayout(main_widget) side_layout = QGridLayout() plot_widget = PlotWidget(main_widget) self.plot_widget = plot_widget list_widget = ListWidget() prop_widget = PropertyWidget() list_widget.registerPropertyWindow(prop_widget) side_layout.addWidget(list_widget, 0, 0) side_layout.addWidget(prop_widget, 1, 0) side_layout.setRowStretch(0, 2) side_layout.setRowStretch(1, 1) self.list_widget = list_widget main_layout.addLayout(side_layout, 0, 0) main_layout.addWidget(plot_widget, 0, 1) main_layout.setColumnStretch(0, 1) main_layout.setColumnStretch(1, 3) self.setCentralWidget(main_widget)
@staticmethod def update_input_text(input_): dialog = QFileDialog() dir_path = unicode(dialog.getExistingDirectory()) if dir_path: input_.setText(dir_path) dialog.destroy() if __name__ == '__main__': app = QApplication(sys.argv) splash_pix = QPixmap("resources/splash.png") splash = QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint) progressBar = QProgressBar(splash) progressBar.setAlignment(QtCore.Qt.AlignCenter) progressBar.setFixedWidth(splash_pix.width()) splash.setMask(splash_pix.mask()) splash.show() t = QtCore.QElapsedTimer() t.start() progressBar.setMaximum(1000) while (t.elapsed() < 1000): progressBar.setValue(t.elapsed()) window = MainWindow() splash.finish(window) window.show() sys.exit(app.exec_())