def on_mouse_action(self, method_name, event):
        """Call colliding object if has appropriate method.

        The object may be the colors panel or one of the
        buttons.

        Parameters
        ==========

        method_name (string)
            name of method to look for in object.
        event (pygame.event.Event instance)
            event.type is either pygame.MOUSEBUTTONDOWN
            or MOUSEBUTTONUP;

            we use its 'pos' attribute, which contains
            the position of the mouse when the event
            occurred;

            required in order to comply with mouse
            action protocol;

            Check pygame.event module documentation on
            pygame website for more info about this event
            object;
        """
        ### retrieve the mouse position
        mouse_pos = event.pos

        ### iterate over the colors panel and the buttons

        for obj in (self.colors_panel, *self.buttons):

            ## check whether the object being iterated
            ## collides with the mouse

            if obj.rect.collidepoint(mouse_pos):

                ## now that we now this object collides
                ## with the mouse, check whether the
                ## object has an attribute named according
                ## to the value in the 'method_name'
                ## argument
                try:
                    method = getattr(obj, method_name)

                ## if it hasn't, then we just pass
                except AttributeError:
                    pass

                ## otherwise we execute the method contained
                ## in such attribute, passing the event
                ## object as an argument
                else:
                    method(event)

                ## regardless of whether or not the object
                ## had an operation retrieved and executed
                ## in the last clauses, break out of the
                ## "for loop"
                break
Call colliding object if has appropriate method.

        The object may be the colors panel or one of the
        buttons.

        Parameters
        ==========

        method_name (string)
            name of method to look for in object.
        event (pygame.event.Event instance)
            event.type is either pygame.MOUSEBUTTONDOWN
            or MOUSEBUTTONUP;

            we use its 'pos' attribute, which contains
            the position of the mouse when the event
            occurred;

            required in order to comply with mouse
            action protocol;

            Check pygame.event module documentation on
            pygame website for more info about this event
            object;
        
nodezator/colorsman/editor/loopop.py