from simian.gui import Form, component, composed_component, utils


class {class_name}(composed_component.Builder):
    def __init__(self, parent: component.Composed):
        super().__init__()

        # Add components from JSON definition.
        parent.addFromJson(__file__.replace(".py", ".json"))

    # @staticmethod
    # def create(key, parent, first_parameter=None, second_parameter=None):
    #     """Create the composed component.

    #     Call to create and initialize the composed component programatically. It creates the
    #     composed component placeholder and adds it to the parent component. Then it loads the
    #     composed component by setting its className property. Lastly, a call to the component
    #     initialization is made to pass the (optional) parameters.

    #     Usage:
    #         {class_name}.create("key", form, first_parameter="Your name", second_parameter="Click me!")
    #     """
    #     composed = component.Composed(key, parent)
    #     composed.className = "{module_name}.{class_name}"

    #     {class_name}._initialize_component(composed, first_parameter, second_parameter)

    #     return composed

    # @staticmethod
    # def get_initializer(first_parameter=None, second_parameter=None):
    #     """Get a component initializer with enclosed parameters.

    #     To be able to parametrize composed components that are loaded from a Json form definition,
    #     use the Form.componentInitializer. This function is an example of how to pass (optional)
    #     parameters to an initialization function.

    #     Usage:
    #         In gui_init add the component initializer before creating the form from Json:

    #         Form.componentInitializer(
    #             key={class_name}.get_initializer(
    #                 first_parameter="Your name", second_parameter="Click me!"
    #             )
    #         )

    #         Replace "key" with the actual key of the composed component.
    #     """
    #     return lambda comp: {class_name}._initialize_component(comp, first_parameter, second_parameter)

    # @staticmethod
    # def _initialize_component(comp: component.Composed, first_parameter, second_parameter):
    #     """Initialize the component using the parameters.

    #     This function is an example of how to use parameters to initialize a composed component. In
    #     this example the parameters are used to set the labels of the two components.
    #     """
    #     [first_component, second_component] = comp.components

    #     if first_parameter:
    #         first_component.label = first_parameter

    #     if second_parameter:
    #         second_component.label = second_parameter
