def simple_polygon_without_brush(layer, width='0.26', color=QColor('black')):
    """Simple style to apply a border line only to a polygon layer.

    :param layer: The layer to style.
    :type layer: QgsVectorLayer

    :param color: Color to use for the line. Default to black.
    :type color: QColor

    :param width: Width to use for the line. Default to '0.26'.
    :type width: str
    """
    registry = QgsApplication.symbolLayerRegistry()
    line_metadata = registry.symbolLayerMetadata("SimpleLine")
    symbol = QgsSymbol.defaultSymbol(layer.geometryType())

    # Line layer
    line_layer = line_metadata.createSymbolLayer(
        {
            'width': width,
            'color': color.name(),
            'offset': '0',
            'penstyle': 'solid',
            'use_custom_dash': '0',
            'joinstyle': 'bevel',
            'capstyle': 'square'
        })

    # Replace the default layer with our custom line
    symbol.deleteSymbolLayer(0)
    symbol.appendSymbolLayer(line_layer)

    renderer = QgsSingleSymbolRenderer(symbol)
    layer.setRenderer(renderer)
def simple_polygon_without_brush ( layer , width = '0.26' , color = QColor ( 'black' ) ) : registry = QgsApplication . symbolLayerRegistry ( ) line_metadata = registry . symbolLayerMetadata ( "SimpleLine" ) symbol = QgsSymbol . defaultSymbol ( layer . geometryType ( ) ) line_layer = line_metadata . createSymbolLayer ( { 'width' : width , 'color' : color . name ( ) , 'offset' : '0' , 'penstyle' : 'solid' , 'use_custom_dash' : '0' , 'joinstyle' : 'bevel' , 'capstyle' : 'square' } ) symbol . deleteSymbolLayer ( 0 ) symbol . appendSymbolLayer ( line_layer ) renderer = QgsSingleSymbolRenderer ( symbol ) layer . setRenderer ( renderer )
Simple style to apply a border line only to a polygon layer.

    :param layer: The layer to style.
    :type layer: QgsVectorLayer

    :param color: Color to use for the line. Default to black.
    :type color: QColor

    :param width: Width to use for the line. Default to '0.26'.
    :type width: str