def __init__(
        self,
        value="",
        loop_holder=None,
        font_height=ENC_SANS_BOLD_FONT_HEIGHT,
        font_path=ENC_SANS_BOLD_FONT_PATH,
        width=155,
        name="string_entry",
        command=empty_function,
        validation_command=None,
        formatting_command=return_untouched,
        update_behind=empty_function,
        draw_behind=empty_function,
        draw_on_window_resize=empty_function,
        coordinates_name="topleft",
        coordinates_value=(0, 0),
        foreground_color=STRING_ENTRY_FG,
        background_color=STRING_ENTRY_BG,
    ):
        """Perform setups and assign data for reuse.

        Parameters
        ==========
        loop_holder (class w/ specific operations or None)
            obj with handle_input-update-draw operations; None
            can also be passed, in which case it means
            the loop holder will be the WindowManager
            class from the module winman.main.
        value (string)
            initial value of the widget.
        font_height (integer)
            desired font height in pixels.
        font_path (string, defaults to "default")
            represents font style. Check local
            font.py module for available styles. In doubt
            use 'default' for default font.
        width (integer)
            width of the widget.
        name (string)
            an arbitrary name to help identify the widget.
        command (callable)
            callable to be executed whenever the value
            changes at the end of an editing session.
        validation_command (None, string or callable)
            if it is None, the instance is set up so that
            no validation is done.

            If it is a string, it must be a key in a
            preset map used to grab a valid command, for
            instance, the name of a built-in "str" method
            to use as the validation command.

            If it is a callable, it must accept a single
            argument and its return value is used to
            determine whether validation passed (when the
            return value is truthy value) or not (when it
            is not truthy).
        formatting_command (callable)
            It must accept a single argument, which is the
            string displayed in the widget, and its return
            value replaces such string in the final value
            of the widget.

            This callable will be used whenever the value
            in the widget is set with self.set.
        update_behind (callable)
            to be called every loop. Can be used to update
            the states of other widgets outside entry
            (useful when the objects outside the entry
            change their appearance over time or in
            response to the contents of this entry while
            you type)
        draw_behind (callable)
            to be called every loop. Can be used to draw
            other widgets outside entry (useful when the
            objects outside the entry change their
            appearance over time or in response to the
            contents of this entry while you type).
        coordinates_name (string)
            represents attribute name of rect wherein
            to store the position information from the
            coordinates value parameter.
        coordinates_value (2-tuple of integers)
            represents a position in 2d space; the values of
            x and y axes, respectively.
        foreground_color, background_color
            (tuple/list/pygame.color.Color instance)
            A tuple or list of r, g, b values which are
            integers ranging from 0 to 255. For the
            background color, an optional fourth value
            can be passed, which is an integer in the
            same range as the others, representing the
            image opacity (0 for full transparency and
            255 for full opacity).
        """
        ### ensure value argument received is a string

        if type(value) is not str:

            raise TypeError("'value' received must be of 'str' type")

        ### convert the colors passed into tuples for
        ### simplicity (since colors can be given as
        ### instances from other classes like
        ### pygame.Color and builtin lists too)

        background_color = tuple(background_color)
        foreground_color = tuple(foreground_color)

        ### store some of the arguments in their own
        ### attributes

        self.name = name
        self.value = value
        self.command = command
        self.loop_holder = loop_holder
        self.formatting_command = formatting_command

        ### store the validation command (this is a
        ### property with setter implementation which
        ### process the given command and also validates
        ### self.value)
        self.validation_command = validation_command

        ### create and position a rect for this entry

        self.rect = Rect(0, 0, width, font_height)

        setattr(self.rect, coordinates_name, coordinates_value)

        ### create a background surface for the widget

        self.background = render_rect(width, font_height, background_color)

        ### also store a copy of it as the image
        ### representing this widget
        self.image = self.background.copy()

        ### gather the text rendering settings in a
        ### dictionary

        render_settings = {
            "font_height": font_height,
            "font_path": font_path,
            "foreground_color": foreground_color,
            "background_color": background_color,
        }

        ### instantiate the entry cursor class, which is
        ### responsible for holding and managing the text
        ### of the entry during edition (while the actual
        ### value keeps stored in the 'value' attribute,
        ### until the edition in the entry is confirmed
        ### or the value is set with self.set())

        self.cursor = EntryCursor(
            value,
            render_settings,
            self,
            get_contrasting_bw(background_color),
        )

        ### update the surface of the widget
        self.update_image()

        ### store behaviours

        self.update_behind = update_behind
        self.draw_behind = draw_behind

        self.draw_on_window_resize = draw_on_window_resize

        ### define behaviours

        self.draw = super().draw
        self.update = empty_function
        self.handle_input = self.handle_events
Perform setups and assign data for reuse.

        Parameters
        ==========
        loop_holder (class w/ specific operations or None)
            obj with handle_input-update-draw operations; None
            can also be passed, in which case it means
            the loop holder will be the WindowManager
            class from the module winman.main.
        value (string)
            initial value of the widget.
        font_height (integer)
            desired font height in pixels.
        font_path (string, defaults to "default")
            represents font style. Check local
            font.py module for available styles. In doubt
            use 'default' for default font.
        width (integer)
            width of the widget.
        name (string)
            an arbitrary name to help identify the widget.
        command (callable)
            callable to be executed whenever the value
            changes at the end of an editing session.
        validation_command (None, string or callable)
            if it is None, the instance is set up so that
            no validation is done.

            If it is a string, it must be a key in a
            preset map used to grab a valid command, for
            instance, the name of a built-in "str" method
            to use as the validation command.

            If it is a callable, it must accept a single
            argument and its return value is used to
            determine whether validation passed (when the
            return value is truthy value) or not (when it
            is not truthy).
        formatting_command (callable)
            It must accept a single argument, which is the
            string displayed in the widget, and its return
            value replaces such string in the final value
            of the widget.

            This callable will be used whenever the value
            in the widget is set with self.set.
        update_behind (callable)
            to be called every loop. Can be used to update
            the states of other widgets outside entry
            (useful when the objects outside the entry
            change their appearance over time or in
            response to the contents of this entry while
            you type)
        draw_behind (callable)
            to be called every loop. Can be used to draw
            other widgets outside entry (useful when the
            objects outside the entry change their
            appearance over time or in response to the
            contents of this entry while you type).
        coordinates_name (string)
            represents attribute name of rect wherein
            to store the position information from the
            coordinates value parameter.
        coordinates_value (2-tuple of integers)
            represents a position in 2d space; the values of
            x and y axes, respectively.
        foreground_color, background_color
            (tuple/list/pygame.color.Color instance)
            A tuple or list of r, g, b values which are
            integers ranging from 0 to 255. For the
            background color, an optional fourth value
            can be passed, which is an integer in the
            same range as the others, representing the
            image opacity (0 for full transparency and
            255 for full opacity).
        
nodezator/widget/stringentry.py