예제 #1
0
    def __repr__(self):
        r = _Composition.__repr__(self)[:-2]

        if len(self) > 0:
            for z, fraction in self.items():
                r += ', %s=%s' % (ep.get_symbol(z), fraction)

        return r + ')>'
예제 #2
0
 def selectionSymbol(self):
     selection = self.selection()
     if self.isMultipleSelection():
         return frozenset(map(get_symbol, selection))
     else:
         if selection is None:
             return None
         else:
             return get_symbol(selection)
예제 #3
0
파일: widgets.py 프로젝트: shrx/moldy
 def selection(self):
     selection = None
     for widget in self._group.buttons():
         if widget.isChecked():
             selection = self._group.id(widget)
     if selection != None:
         return [selection, get_symbol(selection)]
     else:
         return None
예제 #4
0
    def __init__(self, atomic_number, parent=None):
        QPushButton.__init__(self, parent)

        self._atomic_number = atomic_number
        self._symbol = get_symbol(atomic_number)

        self.setText(self._symbol)

        font = self.font()
        font.setWeight(QFont.Bold)
        self.setFont(font)

        self.setSizePolicy(QSizePolicy.MinimumExpanding,
                           QSizePolicy.MinimumExpanding)

        self.setDefault(False)
        self.setAutoDefault(False)
예제 #5
0
        def data(self, index, role):
            if not index.isValid() or \
                    not (0 <= index.row() < len(self.composition)):
                return None

            if role == Qt.TextAlignmentRole:
                return Qt.AlignCenter

            if role != Qt.DisplayRole:
                return None

            z, fraction = list(self.composition.items())[index.row()]
            column = index.column()
            if column == 0:
                if z is None:
                    return 'none'
                else:
                    return str(get_symbol(z))
            elif column == 1:
                return str(fraction)
 def testsymbol(self):
     self.assertEqual('H', get_symbol(1))
     self.assertEqual('Uuo', get_symbol(118))
예제 #7
0
 def setAtomicNumber(self, z):
     self.setText(get_symbol(z))
예제 #8
0
 def get_symbol(self):
     """
     Returns the symbol.
     """
     return get_symbol(self.atomic_number)