def build_option_widget(option, role_to_maps, set_method):
    """Build a option widget from given arguments.

    Parameters
    ==========
    option (string, integer, float, bool or None)
        the value of one of the options available to the
        user.
    role_to_maps (dict)
        its keys are strings representing roles of surfaces
        and its values are other dictionaries; this other
        dictionaries contain strings representing option
        text as keys and the values are the respective
        text surfaces for those strings.
    set_method (callable)
        set() method of the option menu instance; used to
        set the option as the new value of the option menu
        instance when the user clicks the option widget
        (actually, when the mouse is released over it).
    """
    ### instantiate object
    obj = Object2D()

    ### reference surfaces locally according to their
    ### roles/purposes and the text of the option

    option_text = str(option)

    chosen_surf = role_to_maps["chosen"][option_text]
    hovered_surf = role_to_maps["hovered"][option_text]
    unhovered_surf = role_to_maps["unhovered"][option_text]

    ### define surface switching behaviours

    obj.unhighlight = partial(setattr, obj, "image", unhovered_surf)

    obj.highlight = partial(setattr, obj, "image", hovered_surf)

    ### define image and rect attributes for the object

    obj.image = unhovered_surf
    obj.rect = unhovered_surf.get_rect()

    ### reference the chosen_surf in the instance attribute
    ### of the obj using the same name as the variable
    obj.chosen_surf = chosen_surf

    ### store a partial on the 'select' attribute of the
    ### widget that causes it to be selected
    obj.select = partial(set_method, option)

    ### define function complying with the mouse interaction
    ### protocol making it so it executes the command

    def on_mouse_release(event):
        """Set option as the new value of the option menu.

        Parameters
        ==========

        event
            pygame.event.Event of pygame.MOUSEBUTTONUP type;

            although not used, it is required in order to
            comply with protocol used;

            check pygame.event module documentation on
            pygame website for more info about this event
            object.
        """
        set_method(option)

    ### assign the function we just defined to the obj
    ### attribute with the same name
    obj.on_mouse_release = on_mouse_release

    ### store the option in the 'value' attribute of the obj
    obj.value = option

    ### finally return the obj
    return obj
Build a option widget from given arguments.

    Parameters
    ==========
    option (string, integer, float, bool or None)
        the value of one of the options available to the
        user.
    role_to_maps (dict)
        its keys are strings representing roles of surfaces
        and its values are other dictionaries; this other
        dictionaries contain strings representing option
        text as keys and the values are the respective
        text surfaces for those strings.
    set_method (callable)
        set() method of the option menu instance; used to
        set the option as the new value of the option menu
        instance when the user clicks the option widget
        (actually, when the mouse is released over it).
    
nodezator/widget/optionmenu/main.py