TabArray#
- class TabArray(**kwargs)#
A PangoTabArray
contains an array of tab stops.
PangoTabArray
can be used to set tab stops in a PangoLayout
.
Each tab stop has an alignment, a position, and optionally
a character to use as decimal point.
Constructors#
- class TabArray
- classmethod new(initial_size: int, positions_in_pixels: bool) TabArray #
Creates an array of
initial_size
tab stops.Tab stops are specified in pixel units if
positions_in_pixels
isTrue
, otherwise in Pango units. All stops are initially at position 0.- Parameters:
initial_size – Initial number of tab stops to allocate, can be 0
positions_in_pixels – whether positions are in pixel units
Methods#
- class TabArray
-
- classmethod from_string() TabArray | None #
Deserializes a
PangoTabArray
from a string.This is the counterpart to
to_string
. See that functions for details about the format.Added in version 1.50.
- get_decimal_point(tab_index: int) str #
Gets the Unicode character to use as decimal point.
This is only relevant for tabs with
DECIMAL
alignment, which align content at the first occurrence of the decimal point character.The default value of 0 means that Pango will use the decimal point according to the current locale.
Added in version 1.50.
- Parameters:
tab_index – the index of a tab stop
- get_positions_in_pixels() bool #
Returns
True
if the tab positions are in pixels,False
if they are in Pango units.
- get_tab(tab_index: int) Tuple[TabAlign, int] #
Gets the alignment and position of a tab stop.
- Parameters:
tab_index – tab stop index
- get_tabs() Tuple[TabAlign, list[int]] #
If non-
None
,alignments
andlocations
are filled with allocated arrays.The arrays are of length
get_size
. You must free the returned array.
- resize(new_size: int) None #
Resizes a tab array.
You must subsequently initialize any tabs that were added as a result of growing the array.
- Parameters:
new_size – new size of the array
- set_decimal_point(tab_index: int, decimal_point: str) None #
Sets the Unicode character to use as decimal point.
This is only relevant for tabs with
DECIMAL
alignment, which align content at the first occurrence of the decimal point character.By default, Pango uses the decimal point according to the current locale.
Added in version 1.50.
- Parameters:
tab_index – the index of a tab stop
decimal_point – the decimal point to use
- set_positions_in_pixels(positions_in_pixels: bool) None #
Sets whether positions in this array are specified in pixels.
Added in version 1.50.
- Parameters:
positions_in_pixels – whether positions are in pixels
- set_tab(tab_index: int, alignment: TabAlign, location: int) None #
Sets the alignment and location of a tab stop.
- Parameters:
tab_index – the index of a tab stop
alignment – tab alignment
location – tab location in Pango units
- sort() None #
Utility function to ensure that the tab stops are in increasing order.
Added in version 1.50.
- to_string() str #
Serializes a
PangoTabArray
to a string.In the resulting string, serialized tabs are separated by newlines or commas.
Individual tabs are serialized to a string of the form
[ALIGNMENT:]POSITION[:DECIMAL_POINT]
Where ALIGNMENT is one of left, right, center or decimal, and POSITION is the position of the tab, optionally followed by the unit px. If ALIGNMENT is omitted, it defaults to left. If ALIGNMENT is decimal, the DECIMAL_POINT character may be specified as a Unicode codepoint.
Note that all tabs in the array must use the same unit.
A typical example:
100px 200px center:300px right:400px
Added in version 1.50.