def _referenceLineSlot(self, ddict): if ddict['event'] == "returnPressed": current = str(self.referenceLine.text()) current = current.replace(' ', '') if (current == '') or (current.upper() == 'AUTO'): pass elif len(current) == 2: current = current.upper()[0] + current.lower()[1] elif len(current) == 1: current = current.upper()[0] else: self.referenceLine.setText('Auto') msg = qt.QMessageBox(self.referenceLine) msg.setIcon(qt.QMessageBox.Critical) msg.setText("Invalid Element %s" % current) msg.exec_() self.referenceLine.setFocus() return if (current == '') or (current.upper() == 'AUTO'): self.referenceLine.setText('Auto') self._mySignal() elif not Elements.isValidFormula(current): self.referenceLine.setText('Auto') msg = qt.QMessageBox(self.referenceLine) msg.setIcon(qt.QMessageBox.Critical) msg.setText("Invalid Element %s" % current) msg.exec_() self.referenceLine.setFocus() else: self.referenceLine.setText(current) self._mySignal()
def materialSignal(self, txt): txt = str(txt) if Elements.isValidFormula(txt): if DEBUG: print("validFormula") elementDict = Elements.getMaterialMassFractions([txt], [1.0]) elif Elements.isValidMaterial(txt): if DEBUG: print("ValidMaterial") elementDict = Elements.getMaterialMassFractions([txt], [1.0]) else: if DEBUG: print("to be defined") msg=qt.QMessageBox.information(self, "Invalid Material %s" % txt, "The material %s is not a valid Formula " \ "nor a valid Material.\n" \ "Please use the material editor to define materials" % txt) self.materialWidget.setEditText(self._lastMaterial) if self.materialEditor.isHidden(): self.materialEditor.show() return # We have to update the possible elements elements = list(elementDict.keys()) self.updateElementsWidget(elements)
def materialSignal(self, txt): txt = str(txt) if Elements.isValidFormula(txt): _logger.debug("validFormula") elementDict = Elements.getMaterialMassFractions([txt], [1.0]) elif Elements.isValidMaterial(txt): _logger.debug("ValidMaterial") elementDict = Elements.getMaterialMassFractions([txt], [1.0]) else: _logger.debug("Material to be defined") msg=qt.QMessageBox.information(self, "Invalid Material %s" % txt, "The material %s is not a valid Formula " \ "nor a valid Material.\n" \ "Please use the material editor to define materials" % txt) self.materialWidget.setEditText(self._lastMaterial) if self.materialEditor.isHidden(): self.materialEditor.show() return # We have to update the possible elements elements = list(elementDict.keys()) self.updateElementsWidget(elements)
def _mySlot(self, ddict): if ddict['event'] == "returnPressed": current = str(self.currentText()) current = current.replace(' ', '') if (current == '') or (current.upper() == 'AUTO'): pass elif len(current) == 2: current = current.upper()[0] + current.lower()[1] elif len(current) == 1: current = current.upper()[0] else: msg = qt.QMessageBox(self._lineEdit) msg.setIcon(qt.QMessageBox.Critical) msg.setText("Invalid Element %s" % current) msg.exec_() self._lineEdit.setFocus() if not Elements.isValidFormula(current): msg = qt.QMessageBox(self._lineEdit) msg.setIcon(qt.QMessageBox.Critical) msg.setText("Invalid Element %s" % current) msg.exec_() self._lineEdit.setFocus() else: self.setCurrentText(current)