当前位置: 首页>>代码示例>>Python>>正文


Python Elements.isValidFormula方法代码示例

本文整理汇总了Python中PyMca5.PyMcaPhysics.Elements.isValidFormula方法的典型用法代码示例。如果您正苦于以下问题:Python Elements.isValidFormula方法的具体用法?Python Elements.isValidFormula怎么用?Python Elements.isValidFormula使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyMca5.PyMcaPhysics.Elements的用法示例。


在下文中一共展示了Elements.isValidFormula方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __tableSlot

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import isValidFormula [as 别名]
 def __tableSlot(self,row, col):
     if self.__fillingValues:
         return
     item = self.__table.item(row, col)
     if item is not None:
         _logger.debug("table item is None")
         qstring = item.text()
     else:
         qstring = ""
     if col == 0:
         compound = str(qstring)
         if Elements.isValidFormula(compound):
             pass
         else:
             matkey  = Elements.getMaterialKey(compound)
             if matkey is not None:
                 item.setText(matkey)
             else:
                 msg=qt.QMessageBox(self.__table)
                 msg.setIcon(qt.QMessageBox.Critical)
                 msg.setText("Invalid Formula %s" % compound)
                 msg.exec_()
                 self.__table.setCurrentCell(row, col)
                 return
     else:
         try:
             float(str(qstring))
         except:
             msg=qt.QMessageBox(self.__table)
             msg.setIcon(qt.QMessageBox.Critical)
             msg.setText("Invalid Float")
             msg.exec_()
             self.__table.setCurrentCell(row, col)
             return
     self._updateCurrent()
开发者ID:vasole,项目名称:pymca,代码行数:37,代码来源:MaterialEditor.py

示例2: _referenceLineSlot

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import isValidFormula [as 别名]
 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)
             if QTVERSION < '4.0.0':
                 msg.exec_loop()
             else:
                 msg.exec_()
             self.referenceLine.setFocus()
         else:
             self.referenceLine.setText(current)
             self._mySignal()
开发者ID:alemirone,项目名称:pymca,代码行数:36,代码来源:ConcentrationsWidget.py

示例3: __tableSlot2

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import isValidFormula [as 别名]
    def __tableSlot2(self,row, col):
        if self.__fillingValues:return
        if self.__lastRow is None:
            self.__lastRow = row

        if self.__lastColumn is None:
            self.__lastColumn = col

        item = self.__table.item(self.__lastRow,
                                self.__lastColumn)
        if item is None:
            item = qt.QTableWidgetItem("",qt.QTableWidgetItem.Type)
            self.__table.setItem(self.__lastRow,
                                 self.__lastColumn,
                                 item)
        qstring = item.text()

        if self.__lastColumn == 0:
            compound     = str(qstring)
            if Elements.isValidFormula(compound):
                pass
            else:
                matkey  = Elements.getMaterialKey(compound)
                if matkey is not None:
                    item = self.__table.item(self.__lastRow,
                                        self.__lastColumn)
                    if item is None:
                        item = qt.QTableWidgetItem(matkey,
                                        qt.QTableWidgetItem.Type)
                        self.__table.setItem(self.__lastRow,
                                         self.__lastColumn,
                                         item)
                    else:
                        item.setText(matkey)
                else:
                    msg=qt.QMessageBox(self.__table)
                    msg.setIcon(qt.QMessageBox.Critical)
                    msg.setText("Invalid Formula %s" % compound)
                    msg.exec_()
                    self.__table.setCurrentCell(self.__lastRow, self.__lastColumn)
                    return
        else:
            try:
                float(str(qstring))
            except:
                msg=qt.QMessageBox(self.__table)
                msg.setIcon(qt.QMessageBox.Critical)
                msg.setText("Invalid Float")
                msg.exec_()
                self.__table.setCurrentCell(self.__lastRow, self.__lastColumn)
                return
        self._updateCurrent()
开发者ID:vasole,项目名称:pymca,代码行数:54,代码来源:MaterialEditor.py

示例4: validate

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import isValidFormula [as 别名]
 def validate(self, qstring, pos):
     text = str(qstring)
     if text == '-':
         return (self.Valid, pos)
     try:
         # this test is needed even if pyflakes complains!
         float(text)
         return (self.Invalid, pos)
     except:
         pass
     if text.endswith(' '):
         return (self.Invalid, pos)
     if Elements.isValidFormula(text):
         return (self.Valid, pos)
     elif Elements.isValidMaterial(text):
         return (self.Valid, pos)
     else:
         return (self.Invalid,pos)
开发者ID:vasole,项目名称:pymca,代码行数:20,代码来源:MaterialEditor.py

示例5: _checkDensityThickness

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import isValidFormula [as 别名]
 def _checkDensityThickness(self, text, row):
     try:
         currentDensity = float(str(self.text(row, 3)))
     except:
         currentDensity = 0.0
     try:
         currentThickness = float(str(self.text(row, 4)))
     except:
         currentThickness = 0.0
     defaultDensity = -1.0
     defaultThickness = -0.1
     #check if default density is there
     if Elements.isValidFormula(text):
         #check if single element
         if text in Elements.Element.keys():
             defaultDensity = Elements.Element[text]['density']
         else:
             elts = [ w for w in re.split('[0-9]', text) if w != '']
             nbs = [ int(w) for w in re.split('[a-zA-Z]', text) if w != '']
             if len(elts) == 1 and len(nbs) == 1:
                 defaultDensity = Elements.Element[elts[0]]['density']
     elif Elements.isValidMaterial(text):
         key = Elements.getMaterialKey(text)
         if key is not None:
             if 'Density' in Elements.Material[key]:
                 defaultDensity = Elements.Material[key]['Density']
             if 'Thickness' in Elements.Material[key]:
                 defaultThickness = Elements.Material[key]['Thickness']
     if defaultDensity >= 0.0:
         self.setText(row, 3, "%g" % defaultDensity)
     elif currentDensity <= 0:
         # should not be better to raise an exception if the
         # entered density or thickness were negative?
         self.setText(row, 3, "%g" % 1.0)
     if defaultThickness >= 0.0:
         self.setText(row, 4, "%g" % defaultThickness)
     elif currentThickness <= 0.0:
         # should not be better to raise an exception if the
         # entered density or thickness were negative?
         self.setText(row, 4, "%g" % 0.1)
开发者ID:dnaudet,项目名称:pymca,代码行数:42,代码来源:AttenuatorsTable.py

示例6: _mySlot

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import isValidFormula [as 别名]
 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)
开发者ID:alemirone,项目名称:pymca,代码行数:26,代码来源:ConcentrationsWidget.py

示例7: _mySignal

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import isValidFormula [as 别名]
    def _mySignal(self, qstring0):
        qstring = qstring0
        text = str(qstring0)
        if text == '-':
            return
        (result, index) = self.ownValidator.validate(qstring,0)
        if result != self.ownValidator.Valid:
            qstring = self.ownValidator.fixup(qstring)
            (result, index) = self.ownValidator.validate(qstring,0)
        if result != self.ownValidator.Valid:
            text = str(qstring)
            if text.endswith(" "):
                msg =  qt.QMessageBox(self)
                msg.setIcon(qt.QMessageBox.Critical)
                msg.setText("Invalid Material Name '%s'\n" % text + \
                            "It ends with a space character.\n")
                msg.exec_()
                msg = qt.QMessageBox.No
            else:
                try:
                    # this test is needed even if pyflakes complains
                    float(text)
                    msg =  qt.QMessageBox(self)
                    msg.setIcon(qt.QMessageBox.Critical)
                    msg.setText("Invalid Material Name %s\n" % text + \
                                "You cannot use a number as material name.\n" +\
                                "Hint: You can use _%s_" % text)
                    msg.exec_()
                    msg = qt.QMessageBox.No
                except:
                    msg=qt.QMessageBox.information( self, "Invalid Material %s" % str(qstring),
                                          "The material %s is not a valid Formula " \
                                          "nor a valid Material.\n" \
                                          "Do you want to define the material %s\n" % \
                                          (str(qstring), str(qstring)),
                                          qt.QMessageBox.Yes,qt.QMessageBox.No)
            if msg == qt.QMessageBox.No:
                self.setCurrentIndex(0)
                for i in range(self.count()):
                    selftext = self.itemText(i)
                    if selftext == qstring0:
                        self.removeItem(i)
                return
            else:
                qstring = qstring0
        text = str(qstring)

        if Elements.isValidFormula(text):
            msg =  qt.QMessageBox(self)
            msg.setIcon(qt.QMessageBox.Critical)
            msg.setText("Invalid Material Name %s\n" % text + \
                        "The material is a valid Formula.\n " \
                        "There is no need to define it.")
            msg.exec_()
            self.setCurrentIndex(0)
            for i in range(self.count()):
                selftext = self.itemText(i)
                if selftext == qstring0:
                    self.removeItem(i)
                    break
            return
        self.setCurrentText(text)
        self.lastText = text
        ddict = {}
        ddict['event'] = 'activated'
        ddict['row']   = self.row
        ddict['col']   = self.col
        ddict['text']  = text
        if qstring0 != qstring:
            self.removeItem(self.count()-1)

        insert = True
        for i in range(self.count()):
            selftext = self.itemText(i)
            if qstring == selftext:
                insert = False
        if insert:
            self.insertItem(self.count(), qstring)

        self.sigMaterialComboBoxSignal.emit(ddict)
开发者ID:vasole,项目名称:pymca,代码行数:82,代码来源:MaterialEditor.py


注:本文中的PyMca5.PyMcaPhysics.Elements.isValidFormula方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。