def on_mouse_release(self, event):
        """Select/unselect colors or invoke buttons.

        If a color widget is hovered by the mouse when
        its left button is release, the color is
        picked/unpicked, depending on its current state;

        if it is a button which is hovered, that button
        is pressed if it has the appropriate method.

        Method compliant with the mouse action protocol.

        Parameters
        ==========
        event (pygame.event.Event instance)
            event whose event.type is MOUSEBUTTONUP;
            it is used to retrieve the position of the
            mouse when its left button was released,
            stored in its 'pos' attribute.
        """
        ### retrieve the mouse position
        mouse_pos = event.pos

        ### iterate over each color widget, toggling the
        ### 'chosen' flag of the one hovered by the mouse
        ### if there is one

        for color_widget in self.color_widgets:

            ## if color widget collides, toggle the
            ## 'chosen' flag, redraw respective surfaces
            ## and the widget outline and break out of
            ## the "for loop"

            if color_widget.rect.collidepoint(mouse_pos):

                color_widget.chosen = not color_widget.chosen

                color_widget.draw()

                if color_widget.chosen:

                    blit_on_screen(color_widget.tick_surf, color_widget.rect)

                ## draw outline around color widget

                draw_rect(
                    SCREEN,
                    color_widget.contrasting_color,
                    color_widget.rect,
                    2,
                )

                break

        ### if no hovered color widget is found,
        ### look between the buttons for the hovered one,
        ### invoking its mouse release action if it has
        ### one

        else:

            ## if a button collides, execute its mouse
            ## release action if it has one (passing the
            ## event object along) and break out of the
            ## "for loop"

            for button in self.buttons:

                if button.rect.collidepoint(mouse_pos):

                    try:
                        method = button.on_mouse_release
                    except AttributeError:
                        pass
                    else:
                        method(event)

                    break
Select/unselect colors or invoke buttons.

        If a color widget is hovered by the mouse when
        its left button is release, the color is
        picked/unpicked, depending on its current state;

        if it is a button which is hovered, that button
        is pressed if it has the appropriate method.

        Method compliant with the mouse action protocol.

        Parameters
        ==========
        event (pygame.event.Event instance)
            event whose event.type is MOUSEBUTTONUP;
            it is used to retrieve the position of the
            mouse when its left button was released,
            stored in its 'pos' attribute.
        
nodezator/colorsman/picker/op.py