def build_form_widgets(self):
        """Build widgets to hold settings for edition."""
        ### create list to hold widgets
        self.widgets = List2D()

        ### define an initial topleft relative to the
        ### topleft corner of the form 'rect'
        topleft = self.rect.move(5, 5).topleft

        ### instantiate a caption for the form

        caption_label = Object2D.from_surface(
            surface=(
                render_text(
                    text=(t.editing.image_export_form.caption),
                    border_thickness=2,
                    border_color=(TEXT_SETTINGS["foreground_color"]),
                    **TEXT_SETTINGS,
                )
            ),
            coordinates_name="topleft",
            coordinates_value=topleft,
        )

        self.widgets.append(caption_label)

        ### update the topleft to a value a bit below
        ### the bottomleft corner of the widgets already
        ### in the versatile list
        topleft = self.widgets.rect.move(0, 20).bottomleft

        ### instantiate widgets for filepath

        ## filepath label

        new_file_label = Object2D.from_surface(
            surface=render_text(
                text=(t.editing.image_export_form.new_image) + ":", **TEXT_SETTINGS
            ),
            coordinates_name="topleft",
            coordinates_value=topleft,
        )

        self.widgets.append(new_file_label)

        ## filepath change button

        midleft = new_file_label.rect.move(5, 0).midright

        change_filepath_button = Button.from_text(
            text=(t.editing.image_export_form.change),
            command=self.change_filepath,
            coordinates_name="midleft",
            coordinates_value=midleft,
            **BUTTON_SETTINGS,
        )

        draw_depth_finish(change_filepath_button.image)

        self.widgets.append(change_filepath_button)

        ## chosen filepath label

        midleft = change_filepath_button.rect.move(5, 0).midright

        placeholder_name = "exported_graph.html"

        self.chosen_filepath_label = Label(
            text= str(Path.home() / placeholder_name),
            name="image_path",
            max_width=325,
            ellipsis_at_end=False,
            coordinates_name="midleft",
            coordinates_value=midleft,
            **TEXT_SETTINGS,
        )

        self.widgets.append(self.chosen_filepath_label)

        ### update the topleft to a value a bit below
        ### the bottomleft corner of the widgets already
        ### in the versatile list
        topleft = self.widgets.rect.move(0, 20).bottomleft

        ### instantiate widgets for image type

        image_type_label = Object2D.from_surface(
            render_text("Image type:", **TEXT_SETTINGS),
            coordinates_name="topleft",
            coordinates_value=topleft,
        )

        self.widgets.append(image_type_label)

        ## option tray for image type

        midleft = image_type_label.rect.move(10, 0).midright

        self.image_type_tray = OptionTray(
            value=".html",
            options=(".html", ".svg", ".png"),
            name="image_type",
            command=self.update_image_type,
            coordinates_name="midleft",
            coordinates_value=midleft,
        )

        self.widgets.append(self.image_type_tray)

        ### update the topleft to a value a bit below
        ### the bottomleft corner of the widgets already
        ### in the versatile list
        topleft = self.widgets.rect.move(0, 20).bottomleft

        ### instantiate widgets for background color

        ## background color label

        bg_color_label = Object2D.from_surface(
            surface=render_text(
                text=(t.editing.image_export_form.background_color) + ":",
                **TEXT_SETTINGS,
            ),
            coordinates_name="topleft",
            coordinates_value=topleft,
        )

        self.widgets.append(bg_color_label)

        ## colorbutton for background color

        midleft = bg_color_label.rect.move(10, 0).midright

        bg_colorbutton = ColorButton(
            value=GRAPH_BG,
            name="background_color",
            coordinates_name="midleft",
            coordinates_value=midleft,
        )

        self.widgets.append(bg_colorbutton)

        ## set default color button

        midleft = bg_colorbutton.rect.move(5, 0).midright

        command = partial(bg_colorbutton.set, GRAPH_BG)

        set_bg_button = Button.from_text(
            text=(t.editing.image_export_form.restore_default),
            command=command,
            coordinates_name="midleft",
            coordinates_value=midleft,
            **BUTTON_SETTINGS,
        )

        draw_depth_finish(set_bg_button.image)

        self.widgets.append(set_bg_button)

        ### update the topleft to a value a bit below
        ### the bottomleft corner of the widgets already
        ### in the versatile list
        topleft = self.widgets.rect.move(0, 20).bottomleft

        ### instantiate widgets for margins

        ## margins label

        text = (t.editing.image_export_form.horizontal_and_vertical) + ":"

        margins_label = Object2D.from_surface(
            surface=render_text(text=text, **TEXT_SETTINGS),
            coordinates_name="topleft",
            coordinates_value=topleft,
        )

        self.widgets.append(margins_label)

        midleft = margins_label.rect.move(10, 0).midright

        for name in ("horizontal_margin", "vertical_margin"):

            entry = IntFloatEntry(
                loop_holder=self,
                value=10,
                name=name,
                width=70,
                min_value=0,
                draw_on_window_resize=self.draw,
                coordinates_name="midleft",
                coordinates_value=midleft,
            )

            midleft = entry.rect.move(10, 0).midright

            self.widgets.append(entry)

        ### update the topleft to a value a bit below
        ### the bottomleft corner of the widgets already
        ### in the versatile list
        topleft = self.widgets.rect.move(0, 20).bottomleft

        ### instantiate widgets for .svg raster previews

        ## raster preview label

        self.preview_kind_label = Object2D.from_surface(
            surface=(
                render_text(
                    text=(t.editing.image_export_form.raster_for_preview) + ":",
                    **TEXT_SETTINGS,
                )
            ),
            coordinates_name="topleft",
            coordinates_value=topleft,
        )

        self.widgets.append(self.preview_kind_label)

        ###

        midleft = self.preview_kind_label.rect.move(5, 0).midright

        self.preview_kind_checkbutton = CheckButton(
            value=True,
            name="raster_for_previews",
            coordinates_name="midleft",
            coordinates_value=midleft,
        )

        self.widgets.append(self.preview_kind_checkbutton)

        ### create and store behaviour for exiting the form
        ### (equivalent to setting the form data to None
        ### and the 'running' flag to False)

        self.cancel = CallList(
            (
                partial(setattr, self, "form_data", None),
                partial(setattr, self, "running", False),
            )
        )

        ### create, position and store form related buttons

        ## submit button

        self.submit_button = Button.from_text(
            text=(t.editing.image_export_form.submit),
            command=self.submit_form,
            **BUTTON_SETTINGS,
        )

        draw_depth_finish(self.submit_button.image)

        self.submit_button.rect.bottomright = self.rect.move(-10, -10).bottomright

        ## cancel button

        self.cancel_button = Button.from_text(
            text=(t.editing.image_export_form.cancel),
            command=self.cancel,
            **BUTTON_SETTINGS,
        )

        draw_depth_finish(self.cancel_button.image)

        self.cancel_button.rect.midright = self.submit_button.rect.move(-5, 0).midleft

        ## store

        self.widgets.extend((self.cancel_button, self.submit_button))
Build widgets to hold settings for edition.
nodezator/editing/imageexport/form.py