get_index_by_position method

get_index_by_position(position)

Gets the index of a tab stop with the specified position in points.

def get_index_by_position(self, position: float):
    ...
ParameterTypeDescription
positionfloat

Examples

Shows how to look up a position to see if a tab stop exists there and obtain its index.

doc = aw.Document()
tab_stops = doc.first_section.body.paragraphs[0].paragraph_format.tab_stops

# Add a tab stop at a position of 30mm.
tab_stops.add(aw.ConvertUtil.millimeter_to_point(30), aw.TabAlignment.LEFT, aw.TabLeader.DASHES)

# A result of "0" returned by "get_index_by_position" confirms that a tab stop
# at 30mm exists in this collection, and it is at index 0.
self.assertEqual(0, tab_stops.get_index_by_position(aw.ConvertUtil.millimeter_to_point(30)))

# A "-1" returned by "get_index_by_position" confirms that
# there is no tab stop in this collection with a position of 60mm.
self.assertEqual(-1, tab_stops.get_index_by_position(aw.ConvertUtil.millimeter_to_point(60)))

See Also