def createSec(self): odmpath = self.odmText.text() axispath = self.axisText.text() if not os.path.exists(odmpath): QtWidgets.QMessageBox("Error", "Odm file not found.") return if not os.path.exists(axispath): QtWidgets.QMessageBox("Error", "Axis file not found.") return outpath = QtWidgets.QFileDialog.getSaveFileName( caption="Select output file", filter="*.qpalsWSM") if isinstance(outpath, tuple): outpath = outpath[0] self.WSMProj.odmpath = odmpath self.WSMProj.axispath = axispath self.WSMProj.savepath = outpath[0] self.WSMProj.overlap = self.overlapSpin.value() self.WSMProj.depth = self.depthSpin.value() self.WSMProj.width = self.widthSpin.value() self.WSMProj.attr = self.attrSel.currentText() self.prjBox.setEnabled(False) module = QpalsModuleBase.QpalsModuleBase(execName=os.path.join( self.project.opalspath, "opalsSection.exe"), QpalsProject=self.project) infile = QpalsParameter('inFile', odmpath, None, None, None, None, None) axisfile = QpalsParameter('axisFile', axispath, None, None, None, None, None) attribute = QpalsParameter('attribute', self.attrSel.currentText(), None, None, None, None, None) overlap = QpalsParameter('overlap', str(self.overlapSpin.value() / 100), None, None, None, None, None) thickness = QpalsParameter( 'patchSize', '%s;%s' % (self.widthSpin.value(), self.depthSpin.value()), None, None, None, None, None) outParamFileH = tempfile.NamedTemporaryFile(suffix='.xml', delete=True) self.outParamFile = outParamFileH.name outParamFileH.close() outParamFileParam = QpalsParameter('outParamFile', self.outParamFile, None, None, None, None, None) module.params += [ infile, axisfile, thickness, attribute, overlap, outParamFileParam ] thread, worker = module.run_async(status=self.update_status, on_finish=self.parse_output, on_error=self.sec_error) self.threads.append(thread) self.workers.append(worker)
def writeVrt(self): content = self.prepareVrt() vrtPath = self.vrtPath() file = QtCore.QFile(vrtPath) if file.exists(): if file.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text): oldContent = file.readAll() file.close() if content == oldContent: return True msgBox = QtWidgets.QMessageBox() msgBox.setText(u"The file {} already exist.".format(vrtPath)) msgBox.setInformativeText(u"Do you want to overwrite ?") msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel) msgBox.setDefaultButton(QtWidgets.QMessageBox.Cancel) ret = msgBox.exec_() if ret == QtWidgets.QMessageBox.Cancel: return False QtCore.QFile.remove(vrtPath) if not file.open(QtCore.QIODevice.ReadWrite | QtCore.QIODevice.Text): self.warning(u"Impossible to open VRT file {}".format(vrtPath)) return False file.write(content) file.close() return True
def error(self, msg): msgBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning, "AVISO", u"%s" % msg, QtWidgets.QMessageBox.NoButton, None) msgBox.addButton("OK", QtWidgets.QMessageBox.AcceptRole) # msgBox.addButton("&Continue", QtGui.QMessageBox.RejectRole) msgBox.exec_()
def message_box(message, title, box_type=None): box_type = box_type or MessageBox.INFORMATION mes_box = QtWidgets.QMessageBox(box_type, title, message) mes_box.show() mes_box.exec_()
def switchLayerMaskLabels(): if leyenda.mask is None: qtWdg.QMessageBox().information(None, "Test", "Sin máscara") return capa = leyenda.currentLayer() leyenda.mask.switch(capa) if leyenda.capaVisible(capa): leyenda.canvas.redrawAllLayers()
def displayParamMsgBox(self, param): msg = QtWidgets.QMessageBox(self.parent) msg.setIcon(QtWidgets.QMessageBox.Question) msg.setText(param.desc) msg.setInformativeText(param.longdesc) msg.setWindowTitle(param.name) msg.setStandardButtons(QtWidgets.QMessageBox.Ok) msg.exec_()
def messageDialog(iface=None, title="Concluído", info="", message=""): msgBox = QtWidgets.QMessageBox(iface) msgBox.setIcon(QtWidgets.QMessageBox.Question) msgBox.setWindowTitle(title) msgBox.setText(message) msgBox.setInformativeText(info) msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok) msgBox.setDefaultButton(QtWidgets.QMessageBox.Ok) # msgBox.show() return msgBox.exec_() == QtWidgets.QMessageBox.Ok
def deleteContact(self): message = qwidgets.QMessageBox() message.setModal(True) message.setWindowTitle(u'Remover contacto?') message.setIcon(qwidgets.QMessageBox.Warning) message.setText( u"Tem a certeza que pretende remover contacto?\n(Operação Irreversivel!)" ) message.addButton(u'Remover', qwidgets.QMessageBox.AcceptRole) message.addButton(u'Cancelar', qwidgets.QMessageBox.RejectRole) ret = message.exec_() if ret == qwidgets.QMessageBox.AcceptRole: self.parent.deleteContact(self) else: return
def testLayerLabels(): msg = "Test Layer Labels" if leyenda.mask is None: msg += '\n' + "- Sin máscara" else: capa = leyenda.currentLayer() msg += '\n' + "Capa: {}".format(capa.name()) if leyenda.mask.labelsEnabled(capa): on = leyenda.mask.isActive(capa) if on: msg += '\n' + "- Activada" else: msg += '\n' + "- No activada" else: msg += '\n' + "- Sin etiquetas" qtWdg.QMessageBox().information(None, "Test", msg)
def selection_changed(self): index = self.contact_list.currentRow() if self.changes and self.current_contact is not None: message = qwidgets.QMessageBox() message.setModal(True) message.setWindowTitle(u'Existem Alterações.') message.setIcon(qwidgets.QMessageBox.Warning) message.setText(u"Deseja guardar as alterações efectuadas?") message.addButton(u'Guardar', qwidgets.QMessageBox.AcceptRole) message.addButton(u'Cancelar', qwidgets.QMessageBox.RejectRole) ret = message.exec_() if ret == qwidgets.QMessageBox.AcceptRole: self.save_contact() self.contactPanel.setDisabled(False) self.changes = False self.current_contact = self.contact_array[index] self.contact_list.setCurrentRow(index) self.present_contact() self.cancelChanges()
def delete_contact(self): message = qwidgets.QMessageBox() message.setModal(True) message.setWindowTitle(u'Remover contacto?') message.setIcon(qwidgets.QMessageBox.Warning) message.setText(u"Tem a certeza que pretende remover contacto?\n(Operação Irreversivel!)") message.addButton(u'Remover', qwidgets.QMessageBox.AcceptRole) message.addButton(u'Cancelar', qwidgets.QMessageBox.RejectRole) ret = message.exec_() if ret == qwidgets.QMessageBox.AcceptRole: # get current selected index in list index = self.contact_list.currentRow() if index < 0: return self.contact_list.takeItem(index) self.contact_array.pop(index) self.save_contact_array() self.contact_list.clearSelection() self.contactPanel.setDisabled(True) self.current_contact = None self.present_contact() self.changes = False
def validate(self): if not self.revalidate: return self.revalidate = False allmandatoryset = True paramlist = [] self.listitem.setBackground(qtwhite) self.listitem.setToolTip("") for param in self.params: if param.opt == 'mandatory': param.field.setToolTip('') param.field.setStyleSheet('') param.icon.setIcon(WaitIconMandatory) if not param.val: allmandatoryset = False else: param.field.setStyleSheet('') param.field.setToolTip("") param.icon.setIcon(WaitIcon) if param.val: paramlist.append('-' + param.name) for item in param.val.split(";"): paramlist.append(item.strip('"')) if allmandatoryset: self.listitem.setToolTip("All mandatory parameters set and validated.") calld = self.call(0, None, None, '--options', '1', *paramlist) valid = True if calld['returncode'] != 0: valid = False errormodule = "" if "Error in parameter" in calld['stdout']: errortext = calld['stdout'].split("Error in parameter ")[1].split("\n")[0] errormodule = errortext.split(":")[0] errortext = ":".join(errortext.split(":")[1:]) # print errormodule, errortext elif "Ambiguities while matching value" in calld['stdout']: errortext = calld['stdout'].split("ERROR 0001: std::exception: ")[1].split("\n")[0] msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Question) msg.setText(errortext.split(".")[0]) msg.setInformativeText(".".join(errortext.split(".")[1:])) msg.setWindowTitle("Ambiguities while setting parameter values") msg.setStandardButtons(QtWidgets.QMessageBox.Ok) msg.exec_() elif "ERROR 1000: the argument " in calld['stdout']: errortext = calld['stdout'].split("ERROR 1000:")[1].split("\n")[0] errormodule = errortext.split("for option '")[1].split("' is invalid")[0] elif "Applying parsed value to option " in calld['stdout']: errortext = calld['stdout'] errormodule = errortext.split("Applying parsed value to option")[1].split()[0] else: errortext = "Unknown error." raise Exception('Call failed:\n %s' % calld['stdout']) if len(errortext) > 500: errortext = errortext[:500] + " ... (%s more characters)." % len(errortext)-500 errortext += "\nRun the module and look at the log for more details." if errormodule: for param in self.params: if param.name == errormodule: param.field.setToolTip(errortext) param.icon.setIcon(ErrorIcon) param.field.setStyleSheet('background-color: rgb(255,140,140);') break self.listitem.setBackground(qtsoftred) self.listitem.setToolTip(errortext) else: self.listitem.setBackground(qtsoftgreen) parsedXML = parseXML(calld['stderr'])['Specific'] for param in self.params: for parsedParam in parsedXML: if param.name == parsedParam.name and not param.changed: param.field.setText(parsedParam.val) break return valid
def switchAllMaskLabels(): if leyenda.mask is None: qtWdg.QMessageBox().information(None, "Test", "Sin máscara") return leyenda.mask.maskSwitch()
def saveProgress(self): self.WSMProj.save() msg = QtWidgets.QMessageBox() msg.setText("Saving completed!") msg.setWindowTitle("Saving completed!") msg.exec_()
def salutacions(): qtWdg.QMessageBox().information(None, 'qVista', 'Salutacions ' + QvApp().usuari)