The easiest for me would be to check the properties of the symbology layer which contains symbol properties affecting the whole layer:
dir(symbol)
>>>['DynamicRotation', 'Fill', 'Hybrid', 'Line', 'Marker', 'RenderHint', 'RenderHints', 'ScaleArea', 'ScaleDiameter', 'ScaleMethod', 'SymbolType', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_getLineString', '_getPoint', '_getPolygon', '_getPolygonRing', 'appendSymbolLayer', 'asImage', 'bigSymbolPreviewImage', 'changeSymbolLayer', 'clipFeaturesToExtent', 'clone', 'cloneLayers', 'color', 'createSimple', 'defaultSymbol', 'deleteSymbolLayer', 'drawPreviewIcon', 'dump', 'exportImage', 'forceRHR', 'hasDataDefinedProperties', 'insertSymbolLayer', 'layer', 'mapUnitScale', 'opacity', 'outputUnit', 'renderFeature', 'renderHints', 'renderPolygon', 'renderUsingLayer', 'renderVertexMarker', 'setAngle', 'setClipFeaturesToExtent', 'setColor', 'setForceRHR', 'setLayer', 'setMapUnitScale', 'setOpacity', 'setOutputUnit', 'setRenderHints', 'startRender', 'stopRender', 'symbolLayer', 'symbolLayerCount', 'symbolLayers', 'symbolRenderContext', 'takeSymbolLayer', 'toSld', 'type', 'usedAttributes']
To access individual symbol layers inside, you could use:
dir(symbol.symbolLayer(0))
>>>['Property', 'PropertyAngle', 'PropertyArrowHeadLength', 'PropertyArrowHeadThickness', 'PropertyArrowHeadType', 'PropertyArrowStartWidth', 'PropertyArrowType', 'PropertyArrowWidth', 'PropertyAverageAngleLength', 'PropertyBlurRadius', 'PropertyCapStyle', 'PropertyCharacter', 'PropertyCoordinateMode', 'PropertyCustomDash', 'PropertyDisplacementX', 'PropertyDisplacementY', 'PropertyDistanceX', 'PropertyDistanceY', 'PropertyFile', 'PropertyFillColor', 'PropertyFillStyle', 'PropertyGradientReference1IsCentroid', 'PropertyGradientReference1X', 'PropertyGradientReference1Y', 'PropertyGradientReference2IsCentroid', 'PropertyGradientReference2X', 'PropertyGradientReference2Y', 'PropertyGradientSpread', 'PropertyGradientType', 'PropertyHeight', 'PropertyHorizontalAnchor', 'PropertyInterval', 'PropertyJoinStyle', 'PropertyLayerEnabled', 'PropertyLineAngle', 'PropertyLineDistance', 'PropertyName', 'PropertyOffset', 'PropertyOffsetAlongLine', 'PropertyOffsetX', 'PropertyOffsetY', 'PropertyOpacity', 'PropertyPlacement', 'PropertyPreserveAspectRatio', 'PropertySecondaryColor', 'PropertyShapeburstIgnoreRings', 'PropertyShapeburstMaxDistance', 'PropertyShapeburstUseWholeShape', 'PropertySize', 'PropertyStrokeColor', 'PropertyStrokeStyle', 'PropertyStrokeWidth', 'PropertyVerticalAnchor', 'PropertyWidth', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_renderPolygon', 'angle', 'brushStyle', 'clone', 'color', 'copyDataDefinedProperties', 'copyPaintEffect', 'create', 'createFromSld', 'dataDefinedProperties', 'drawPreviewIcon', 'dxfAngle', 'dxfBrushColor', 'dxfBrushStyle', 'dxfColor', 'dxfCustomDashPattern', 'dxfOffset', 'dxfPenStyle', 'dxfWidth', 'enabled', 'estimateMaxBleed', 'fillColor', 'hasDataDefinedProperties', 'isCompatibleWithSymbol', 'isLocked', 'layerType', 'mapUnitScale', 'offset', 'offsetMapUnitScale', 'offsetUnit', 'ogrFeatureStyle', 'outputUnit', 'paintEffect', 'penJoinStyle', 'prepareExpressions', 'properties', 'propertyDefinitions', 'renderPolygon', 'renderingPass', 'restoreOldDataDefinedProperties', 'setAngle', 'setBrushStyle', 'setColor', 'setDataDefinedProperties', 'setDataDefinedProperty', 'setEnabled', 'setFillColor', 'setLocked', 'setMapUnitScale', 'setOffset', 'setOffsetMapUnitScale', 'setOffsetUnit', 'setOutputUnit', 'setPaintEffect', 'setPenJoinStyle', 'setRenderingPass', 'setStrokeColor', 'setStrokeStyle', 'setStrokeWidth', 'setStrokeWidthMapUnitScale', 'setStrokeWidthUnit', 'setSubSymbol', 'startRender', 'stopRender', 'strokeColor', 'strokeStyle', 'strokeWidth', 'strokeWidthMapUnitScale', 'strokeWidthUnit', 'subSymbol', 'toSld', 'type', 'usedAttributes', 'writeDxf']
Near the end of this list of properties, we can see there's settings for setBrushStyle
and setStrokeColor
. The setBrushStyle
requires Qt.BrushStyle
to set a brush style, we can check the properties inside Qt
using:
dir(Qt)
So doing a little search, we can find brush patterns such as BDiagPattern
or FDiagPattern
So now we can apply the relevant settings:
layer = iface.activeLayer()
single_symbol_renderer = layer.renderer()
symbol = single_symbol_renderer.symbol()
#Set fill colour
symbol.setColor(QColor.fromRgb(255,128,0))
#Set fill style
symbol.symbolLayer(0).setBrushStyle(Qt.BrushStyle(Qt.FDiagPattern))
#Set stroke colour
symbol.symbolLayer(0).setStrokeColor(QColor(255,128,0))
#Refresh
layer.triggerRepaint()
iface.layerTreeView().refreshLayerSymbology(layer.id())