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


Python Elements.getMaterialKey方法代码示例

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


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

示例1: __tableSlot

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialKey [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: __nameLineSlot

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialKey [as 别名]
 def __nameLineSlot(self):
     _logger.debug("__nameLineSlot(self)")
     qstring = self.__nameLine.text()
     text = str(qstring)
     if self.__toolMode:
         if len(text):
             matkey = Elements.getMaterialKey(text)
         if matkey is not None:
             self.setCurrent(matkey)
             #Disable everything
             self.__disableInput()
         elif text in Elements.ElementList:
             self.__disableInput()
             name = Elements.Element[text]['name']
             self._current['Comment'] = name[0].upper() + name[1:]
             self._current['CompoundList'] = [text+"1"]
             self._current['CompoundFraction'] = [1.0]
             self._current['Density'] = Elements.Element[text]['density']
             self._fillValues()
             self._updateCurrent()
             self.__nameLine.setText("%s" % text)
         else:
             self._current['Comment'] = text
             self.__numberSpin.setEnabled(True)
             self.__table.setEnabled(True)
             self.__densityLine.setEnabled(True)
             self.__thicknessLine.setEnabled(True)
     else:
         self._current['Comment'] = text
开发者ID:vasole,项目名称:pymca,代码行数:31,代码来源:MaterialEditor.py

示例3: fixup

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialKey [as 别名]
 def fixup(self, qstring):
     if qstring is None:
         return None
     text = str(qstring)
     key  = Elements.getMaterialKey(text)
     if key is not None:
         return QString(key)
     else:
         return qstring
开发者ID:vasole,项目名称:pymca,代码行数:11,代码来源:MaterialEditor.py

示例4: __tableSlot2

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialKey [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

示例5: _checkDensityThickness

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialKey [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: setCurrent

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialKey [as 别名]
 def setCurrent(self, matkey0):
     _logger.debug("setCurrent(self, matkey0=%s)", matkey0)
     matkey = Elements.getMaterialKey(matkey0)
     if matkey is not None:
         if self.__toolMode:
             #make sure the material CANNOT be modified
             self._current = copy.deepcopy(Elements.Material[matkey])
             if self.__table.isEnabled():
                 self.__disableInput()
         else:
             self._current = Elements.Material[matkey]
     else:
         self._setCurrentDefault()
         if not self.__toolMode:
             Elements.Material[matkey0] = self._current
     self.__numberSpin.setFocus()
     try:
         self._fillValues()
         self._updateCurrent()
     finally:
         if self.__toolMode:
             self.__nameLine.setText("%s" % matkey)
         self.__fillingValues = False
开发者ID:vasole,项目名称:pymca,代码行数:25,代码来源:MaterialEditor.py


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