EditorBuilder

class caqtus.gui.autogen.EditorBuilder

Bases: object

Construct widgets to edit values of given types.

Editors must be registered with the builder using the method register_editor() before the method build_editor() is called.

register_editor(
type_: TypeExpr,
factory: EditorFactory,
) None

Specify an editor to use when encountering a given type.

When the method build_editor() is called with this type, this editor will be used.

Warning

If an editor is already registered for this type, it will be overwritten.

build_editor(
type_: TypeExpr,
) EditorFactory

Construct a gui class to edit value of a given type.

This method dispatches the type passed as argument to the editor registered for this type.

If the type is typing.Annotated[T, …], the editor for T will be built.

If the type is not registered, but is an attrs class, an editor will be built for it by calling build_attrs_class_editor().

If the type is not registered but is a Literal, an editor will be built for it by calling build_literal_editor().

If the type is not registered but is an Enum, an editor will be built for it by calling generate_enum_editor().

Raises:

TypeNotRegisteredError – If no editor is registered to handle the given type, and it is not possible to infer an editor from the type.