(char, background=Qt.black, color=Qt.white)
return icon
Create a QIcon with a given character. The icon is 13 pixels high and wide.

    :param char: The character that is printed in the icon
    :type char: str
    :param background: the background color (default: black)
    :type background: QColor
    :param color: the character color (default: white)
    :type color: QColor
    :rtype: QIcon
Create a QIcon with a given character. The icon is 13 pixels high and wide.
Create a QIcon with a given character . The icon is 13 pixels high and wide .
def createAttributePixmap(char, background=Qt.black, color=Qt.white):
    """
    Create a QIcon with a given character. The icon is 13 pixels high and wide.

    :param char: The character that is printed in the icon
    :type char: str
    :param background: the background color (default: black)
    :type background: QColor
    :param color: the character color (default: white)
    :type color: QColor
    :rtype: QIcon
    """
    icon = QtGui.QIcon()
    for size in (13, 16, 18, 20, 22, 24, 28, 32, 64):
        pixmap = QtGui.QPixmap(size, size)
        pixmap.fill(Qt.transparent)
        painter = QtGui.QPainter()
        painter.begin(pixmap)
        painter.setRenderHints(painter.Antialiasing | painter.TextAntialiasing |
                               painter.SmoothPixmapTransform)
        painter.setPen(background)
        painter.setBrush(background)
        margin = 1 + size // 16
        text_margin = size // 20
        rect = QtCore.QRectF(margin, margin,
                             size - 2 * margin, size - 2 * margin)
        painter.drawRoundedRect(rect, 30.0, 30.0, Qt.RelativeSize)
        painter.setPen(color)
        font = painter.font()  # type: QtGui.QFont
        font.setPixelSize(size - 2 * margin - 2 * text_margin)
        painter.setFont(font)
        painter.drawText(rect, Qt.AlignCenter, char)
        painter.end()
        icon.addPixmap(pixmap)
    return icon
def createAttributePixmap ( char , background = Qt . black , color = Qt . white ) : icon = QtGui . QIcon ( ) for size in ( 13 , 16 , 18 , 20 , 22 , 24 , 28 , 32 , 64 ) : pixmap = QtGui . QPixmap ( size , size ) pixmap . fill ( Qt . transparent ) painter = QtGui . QPainter ( ) painter . begin ( pixmap ) painter . setRenderHints ( painter . Antialiasing | painter . TextAntialiasing | painter . SmoothPixmapTransform ) painter . setPen ( background ) painter . setBrush ( background ) margin = 1 + size // 16 text_margin = size // 20 rect = QtCore . QRectF ( margin , margin , size - 2 * margin , size - 2 * margin ) painter . drawRoundedRect ( rect , 30.0 , 30.0 , Qt . RelativeSize ) painter . setPen ( color ) font = painter . font ( ) # type: QtGui.QFont font . setPixelSize ( size - 2 * margin - 2 * text_margin ) painter . setFont ( font ) painter . drawText ( rect , Qt . AlignCenter , char ) painter . end ( ) icon . addPixmap ( pixmap ) return icon