def addSegments(self): self.fileChooser.ok.setEnabled(False) self.segmentList.listWidget.clear() try: self.segmentData = mythread.run_task("Analyzing. This can take a few minutes.", self.dostuff, parent=self) except Exception, e: QMessageBox.critical(self, "An error occured", str(e)) return
def __init__(self, initialPath=None, parent=None): QMainWindow.__init__(self, parent) mainWidget = QWidget(self) self.setCentralWidget(mainWidget) layout = QVBoxLayout(mainWidget) fileChooser = FileChooser("Input", "", True) fileChooser.ok.clicked.connect(self.addSegments) # Show chooser if no initial path was given, otherwise calculate segments right away if initialPath == None: layout.addWidget(fileChooser) else: fileChooser.edit.setText(initialPath) segmentList = SegmentList() layout.addWidget(segmentList) buttons = QDialogButtonBox(QDialogButtonBox.Save | QDialogButtonBox.Close, Qt.Horizontal) buttons.button(QDialogButtonBox.Save).clicked.connect( lambda: mythread.run_task("Saving. This can take a few minutes.", self.save, parent=self) ) buttons.button(QDialogButtonBox.Save).setEnabled(False) buttons.button(QDialogButtonBox.Close).clicked.connect(self.close) layout.addWidget(buttons) self.fileChooser = fileChooser self.segmentList = segmentList self.segmentData = [] self.buttons = buttons self.buildMenu() # Load config self.spec = configobj.ConfigObj(CONFSPEC.split("\n"), list_values=False) self.config = configobj_qt.from_QSettings(QSettings()) self.config.configspec = self.spec self.config.validate(validate.Validator()) if initialPath != None: self.addSegments()