def _visible_layers_count(self):
        """Calculate the number of visible layers in the legend.

        .. versionadded: 3.1

        :returns: Count of layers that are actually visible.
        :rtype: int
        """
        treeroot = QgsProject.instance().layerTreeRoot()
        return len([lyr for lyr in treeroot.findLayers() if lyr.isVisible()])
def _visible_layers_count ( self ) : treeroot = QgsProject . instance ( ) . layerTreeRoot ( ) return len ( [ lyr for lyr in treeroot . findLayers ( ) if lyr . isVisible ( ) ] )
Calculate the number of visible layers in the legend.

        .. versionadded: 3.1

        :returns: Count of layers that are actually visible.
        :rtype: int