Skip to content

Tab

Tab class for “text:tab” tag.

Classes:

Name Description
Tab

Representation of a tabulation, “text:tab”.

Tab

Bases: MDTab, Element

Representation of a tabulation, “text:tab”.

This element represents the [UNICODE] tab character (HORIZONTAL TABULATION, U+0009). The position attribute indicates the number of the tab-stop to which a tab character refers, where position 0 marks the start margin of a paragraph. Layout-oriented consumers should determine tab positions based on style information.

Methods:

Name Description
__init__

Create a tabulation element “text:tab”.

__str__

Attributes:

Name Type Description
position
text str

Get the text content, which is always a tab character.

Source code in odfdo/tab.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class Tab(MDTab, Element):
    """Representation of a tabulation, "text:tab".

    This element represents the [UNICODE] tab character (HORIZONTAL TABULATION,
    U+0009). The position attribute indicates the number of the tab-stop to
    which a tab character refers, where position 0 marks the start margin of
    a paragraph. Layout-oriented consumers should determine tab positions based
    on style information.
    """

    _tag = "text:tab"
    _properties: tuple[PropDef | PropDefBool, ...] = (
        PropDef("position", "text:tab-ref"),
    )

    def __init__(self, position: int | None = None, **kwargs: Any) -> None:
        """Create a tabulation element "text:tab".

        Args:
            position: The position of the tab-stop. If provided,
                must be a non-negative integer.
        """
        super().__init__(**kwargs)
        if self._do_init and position is not None and position >= 0:
            self.position = str(position)

    def __str__(self) -> str:
        return "\t"

    @property
    def text(self) -> str:
        """Get the text content, which is always a tab character.

        Returns:
            str: The tab character ("\t").
        """
        return "\t"

    @text.setter
    def text(self, text: str | None) -> None:
        """Setting text for a tab is a no-op as it always represents a tab character."""
        pass

_properties class-attribute instance-attribute

_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef("position", "text:tab-ref"),
)

_tag class-attribute instance-attribute

_tag = 'text:tab'

position instance-attribute

position = str(position)

text property writable

text: str

Get the text content, which is always a tab character.

Returns:

Name Type Description
str str

The tab character (” “).

__init__

__init__(
    position: int | None = None, **kwargs: Any
) -> None

Create a tabulation element “text:tab”.

Parameters:

Name Type Description Default
position int | None

The position of the tab-stop. If provided, must be a non-negative integer.

None
Source code in odfdo/tab.py
49
50
51
52
53
54
55
56
57
58
def __init__(self, position: int | None = None, **kwargs: Any) -> None:
    """Create a tabulation element "text:tab".

    Args:
        position: The position of the tab-stop. If provided,
            must be a non-negative integer.
    """
    super().__init__(**kwargs)
    if self._do_init and position is not None and position >= 0:
        self.position = str(position)

__str__

__str__() -> str
Source code in odfdo/tab.py
60
61
def __str__(self) -> str:
    return "\t"