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="Socket detection settings",
                    border_thickness=2,
                    border_color=(TEXT_SETTINGS["foreground_color"]),
                    **TEXT_SETTINGS,
                )
            ),
        )

        widgets.append(caption_label)

        ###

        all_rects = self.all_rects
        all_rects.append(widgets.rect)

        ###
        topleft = widgets.rect.move(0, 20).bottomleft

        ###

        socket_detection_graphics_label = Object2D.from_surface(
            surface=(
                render_text(
                    text="Socket detection graphics:",
                    **TEXT_SETTINGS,
                )
            ),
            coordinates_name='topleft',
            coordinates_value=topleft,
        )

        widgets.append(socket_detection_graphics_label)

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

        socket_graphics_option_menu = self.socket_graphics_option_menu = (

            OptionMenu(
                loop_holder=self,
                options=ORDERED_SOCKET_DETECTION_GRAPHICS,
                value=USER_PREFS["SOCKET_DETECTION_GRAPHICS"],
                draw_on_window_resize=self.draw,
                name="SOCKET_DETECTION_GRAPHICS",
                max_width=0,
                coordinates_name='midleft',
                coordinates_value=midleft,
            )

        )

        widgets.append(socket_graphics_option_menu)

        ###

        topleft = widgets.rect.move(0, 20).bottomleft

        ###

        distances_setting_label = Object2D.from_surface(
            surface=(
                render_text(
                    text="Drag hands below to set specific distances:",
                    **TEXT_SETTINGS,
                )
            ),
            coordinates_name='topleft',
            coordinates_value=topleft,
        )

        widgets.append(distances_setting_label)

        ###

        topleft = widgets.rect.move(0, 5).bottomleft

        drect = self.distances_rect = Rect(*topleft, 250, 80)
        x_padded_drect = self.x_padded_drect = drect.inflate(80, 0)
        x_padded_drect.left = 0
        drect.center = x_padded_drect.center

        all_rects.extend((drect, x_padded_drect))

        socket_rect = self.socket_rect = Rect(0, 0, SOCKET_DIAMETER, SOCKET_DIAMETER)
        socket_rect.center = drect.midright

        OPH_RECT.top = drect.centery
        OPH_RECT.y += 5

        detection_distance = USER_PREFS['DETECTION_DISTANCE']
        OPH_RECT.centerx = socket_rect.move(-detection_distance, 0).centerx

        grasping_distance = USER_PREFS['GRASPING_DISTANCE']
        CLH_RECT.midbottom = socket_rect.move(-grasping_distance, 0).center
        CLH_RECT.y += -5

        all_rects.extend((socket_rect, OPH_RECT, CLH_RECT))

        all_rects_man = self.all_rects_man = RectsManager(all_rects.__iter__)

        ###

        topleft = all_rects_man.move(0, 10).bottomleft

        detection_distance_value_label = self.detection_distance_value_label = (

            Label(
                text="000",
                name='DETECTION_DISTANCE',
                coordinates_name='topleft',
                coordinates_value=topleft,
                **NUMBER_LABEL_SETTINGS,
            )

        )

        detection_distance_value_label.set(f'{detection_distance}')

        widgets.append(detection_distance_value_label)

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

        detection_distance_label = Object2D.from_surface(
            surface=(
                render_text(
                    text="pixels for target socket to start reaching for cursor",
                    **TEXT_SETTINGS,
                )
            ),
            coordinates_name='midleft',
            coordinates_value=midleft,
        )

        widgets.append(detection_distance_label)

        ###

        topleft = widgets.rect.move(0, 5).bottomleft

        grasping_distance_value_label = self.grasping_distance_value_label = (

            Label(
                text="000",
                name="grasping_distance",
                coordinates_name='topleft',
                coordinates_value=topleft,
                **NUMBER_LABEL_SETTINGS,
            )

        )

        grasping_distance_value_label.set(f'{grasping_distance}')

        widgets.append(grasping_distance_value_label)

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

        grasping_distance_label = Object2D.from_surface(
            surface=(
                render_text(
                    text="pixels for target socket to grasp the cursor",
                    **TEXT_SETTINGS,
                )
            ),
            coordinates_name='midleft',
            coordinates_value=midleft,
        )

        widgets.append(grasping_distance_label)

        ### create, position and store form related buttons

        ### create form buttons

        ## submit button

        self.finish_button = Button.from_text(
            text="Confirm changes",
            command=CallList(
                [
                    self.finish_form,
                    self.exit_loop,
                ]
            ),
            **BUTTON_SETTINGS,
        )

        draw_depth_finish(self.finish_button.image)

        ## cancel button

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

        draw_depth_finish(self.cancel_button.image)

        ## store

        self.finish_button.rect.topright = all_rects_man.move(0, 20).bottomright

        self.cancel_button.rect.topright = (
            self.finish_button.rect.move(-5, 0).topleft
        )

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