As explained by @xunilk in Getting attribute values from vector features visible in QGIS canvas using PyQGIS we can easily access to the attribute values of the features visible in the QGIS canvas (code below)
layer = iface.activeLayer()
mapcanvas = iface.mapCanvas()
rect = mapcanvas.extent()
request = QgsFeatureRequest().setFilterRect(rect)
selected_feats = layer.getFeatures(request)
attr = [ feat.attributes() for feat in selected_feats ]
print(attr)
However I'm struggling to find a way to display, in the attribute table, only the values of the visible features.
Do you have any suggestions?