this is simpel in pyqgis:
layer = iface.activeLayer() # is the currently selctedselected layer
box = layer.boundingBoxOfSelected() # creates a bounding box
iface.mapCanvas().setExtent(box) # zooms to this boundinboxbounding box
you could also scale the box variable with
box.scale(2,box.center()[0], box.center()[1])
where "2" is the scale factor.
testedTested with QGIS 2.18. For further research have a look athe pyqgis api of boundingBoxOfSelected