Check out this tutorial Tutorials from a-z, How to create schema templates with DynamicComponents and Python