def build_widgets(self):
        """Build widgets to support the colors viewer."""

        ### create and setup a "mode options menu"

        ## instantiate and store the options menu in its
        ## own attribute (also reference it locally)

        mode_options = self.mode_options = OptionMenu(
            loop_holder=self,
            value=MODE_NAMES[0],
            max_width=0,
            options=list(MODE_NAMES),
            draw_on_window_resize=(
                partial(
                    methodcaller("draw"),
                    self,
                )
            ),
        )

        ## define command for the menu and assign it to
        ## its 'command' attribute

        def change_mode():
            """Retrieve mode name from menu and set it."""
            self.set_mode(mode_options.get())

        mode_options.command = change_mode

        ### create and setup a "go back button"

        go_back_button = self.go_back_button = Object2D.from_surface(
            surface=(
                render_text(
                    text="Go back",
                    font_height=ENC_SANS_BOLD_FONT_HEIGHT,
                    padding=5,
                    foreground_color=BUTTON_FG,
                    background_color=BUTTON_BG,
                    depth_finish_thickness=1,
                )
            ),
        )

        go_back_button.on_mouse_release = get_oblivious_callable(
            partial(setattr, self, "running", False)
        )

        ### create a collection to hold buttons and
        ### add the mode options menu and "go back" button
        ### to it

        self.buttons = List2D()
        self.buttons.extend((mode_options, go_back_button))

        ### create a label for the colors viewer

        ## create and store a collection to store labels
        self.labels = List2D()

        ## append a label to indicate the "mode option menu"
        ## to it (other labels will be appended to this
        ## collection, but by other objects, not here)

        modes_label = self.modes_label = Object2D.from_surface(
            surface=(
                render_text(
                    text="Mode:",
                    font_height=ENC_SANS_BOLD_FONT_HEIGHT,
                    padding=5,
                    foreground_color=WINDOW_FG,
                    background_color=WINDOW_BG,
                )
            ),
        )

        self.labels.append(modes_label)

        ### create a pygame.Surface objects to use as a
        ### canvas that can be freely used in different
        ### modes

        canvas_area = self.rect.inflate(-80, -80)

        self.canvas = Object2D.from_surface(
            surface=render_rect(*canvas_area.size),
            coordinates_name="topleft",
            coordinates_value=canvas_area.topleft,
        )
Build widgets to support the colors viewer.
nodezator/colorsman/viewer/main.py