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

        ### instantiate a caption for the form

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

        widgets.append(caption_label)

        ### create specific widgets to pick color index
        ### for each existing node category

        ## number of categories

        no_of_categories = len(NODE_CATEGORY_COLORS)

        for (category_id, index) in APP_REFS.category_index_map.items():

            color_widget = Color2D(
                width=30,
                height=30,
                color=NODE_CATEGORY_COLORS[index],
            )

            ###
            color_widget.category_id = category_id

            ###
            color_setting_command = get_oblivious_callable(
                partial(set_color, color_widget)
            )

            color_widget.on_mouse_release = color_setting_command

            ###
            category_label = Object2D.from_surface(
                surface=(render_text(text=sep.join(category_id), **TEXT_SETTINGS))
            )

            category_label.on_mouse_release = color_setting_command

            ###
            category_widgets = List2D(
                [
                    color_widget,
                    category_label,
                ]
            )

            ###

            category_widgets.rect.snap_rects_ip(
                retrieve_pos_from="midright",
                assign_pos_to="midleft",
                offset_pos_by=(5, 0),
            )

            widgets.append(category_widgets)

        widgets.rect.snap_rects_ip(
            retrieve_pos_from="bottomleft",
            assign_pos_to="topleft",
            offset_pos_by=(0, 5),
        )

        ### create, position and store form related buttons

        ## submit button

        self.finish_button = Button.from_text(
            text=(t.editing.category_colors_form.finish),
            command=CallList(
                [
                    self.finish_form,
                    self.exit_loop,
                ]
            ),
            **BUTTON_SETTINGS
        )

        draw_depth_finish(self.finish_button.image)

        self.finish_button.rect.topright = widgets.rect.move(0, 5).bottomright

        ## cancel button

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

        draw_depth_finish(self.cancel_button.image)

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

        ## store

        widgets.extend((self.cancel_button, self.finish_button))
Build widgets to hold settings for edition.
nodezator/editing/categorycolors.py