Extension to execute python function

Is there a simple extension available to execute python code.

Would be a great way to customize 3DSlicer and allow execution of custom code with a button.

I find my self using code such as this and it would be great to have a button up top…

def threeDDIsplay():
import slicer
segmentationNode = slicer.mrmlScene.GetFirstNodeByClass(‘vtkMRMLSegmentationNode’)
segmentationNode.CreateClosedSurfaceRepresentation()
layoutManager = slicer.app.layoutManager()
threeDWidget = layoutManager.threeDWidget(0)
threeDView = threeDWidget.threeDView()
threeDView.resetFocalPoint()
displayNode = segmentationNode.GetDisplayNode()
displayNode.SetOpacity3D(0.3)
print(‘3D’)

This example may help: