qgis-sample-QgsEditorWidgetRegistry.py
from qgis.gui import QgsEditorWidgetRegistry
from qgis.utils import iface
editor_widget_registry_instance = QgsEditorWidgetRegistry.instance()
print editor_widget_registry_instance.factories()
print editor_widget_registry_instance.factories().keys()
print editor_widget_registry_instance.factory(u'Range')
print editor_widget_registry_instance.factory(u'RelationReference')
layer = iface.activeLayer()
editFormConfig = layer.editFormConfig()
idx = layer.dataProvider().fieldNameIndex('ADM0_A3')
widgetType = editFormConfig.widgetType(idx)
widgetConfig = editFormConfig.widgetConfig(idx)
wrapper = QgsEditorWidgetRegistry.instance().create(
widgetType, layer, idx, widgetConfig, None, None)
widget = wrapper.widget()
"""
Classes below inherit from QgsEditorWidgetFactory and are the one really used.
They are casted
QgsCheckboxWidgetFactory
QgsClassificationWidgetWrapperFactory
QgsColorWidgetFactory
QgsDateTimeEditFactory
QgsEnumerationWidgetFactory
QgsFileNameWidgetFactory
QgsHiddenWidgetFactory
QgsPhotoWidgetFactory
QgsRangeWidgetFactory
QgsRelationReferenceFactory
QgsTextEditWidgetFactory
QgsUniqueValueWidgetFactory
QgsUuidWidgetFactory
QgsValueMapWidgetFactory
QgsValueRelationWidgetFactory
QgsWebViewWidgetFactory
"""