def get_option_obj(text, text_settings):
    """Create and return custom text object.

    Parameters
    ==========
    text (string)
        text to be rendered.
    text_settings (dict)
        contains settings used to define how text should
        be rendered.
    """
    ### render the text according to the given settings
    surf = render_text(text, **text_settings)

    ### retrieve its width and height
    width, height = surf.get_size()

    ### create a new surface 6 pixels wider than the
    ### original one, with the same height; 6 is just
    ### an arbitrary value based on what looks good

    new_surf = render_rect(width + 6, height, text_settings["background_color"])

    ### blit the original surface over the new one,
    ### with their center coordinates aligned

    blit_aligned(
        surf,
        new_surf,
        retrieve_pos_from="center",
        assign_pos_to="center",
    )

    ### finally return an object containing the new surface
    ### as its 'image' attribute and a rect obtained from
    ### the surface as the 'rect' attribute

    return Object2D(image=new_surf, rect=new_surf.get_rect())
Create and return custom text object.

    Parameters
    ==========
    text (string)
        text to be rendered.
    text_settings (dict)
        contains settings used to define how text should
        be rendered.
    
nodezator/widget/optiontray/creation.py