get_effective_tab_stops method

get_effective_tab_stops()

Returns array of all tab stops applied to this paragraph, including applied indirectly by styles or lists.

def get_effective_tab_stops(self):
    ...

Examples

Shows how to set custom tab stops for a paragraph.

doc = aw.Document()
para = doc.first_section.body.first_paragraph
# If we are in a paragraph with no tab stops in this collection,
# the cursor will jump 36 points each time we press the Tab key in Microsoft Word.
self.assertEqual(0, len(doc.first_section.body.first_paragraph.get_effective_tab_stops()))
# We can add custom tab stops in Microsoft Word if we enable the ruler via the "View" tab.
# Each unit on this ruler is two default tab stops, which is 72 points.
# We can add custom tab stops programmatically like this.
tab_stops = doc.first_section.body.first_paragraph.paragraph_format.tab_stops
tab_stops.add(position=72, alignment=aw.TabAlignment.LEFT, leader=aw.TabLeader.DOTS)
tab_stops.add(position=216, alignment=aw.TabAlignment.CENTER, leader=aw.TabLeader.DASHES)
tab_stops.add(position=360, alignment=aw.TabAlignment.RIGHT, leader=aw.TabLeader.LINE)
# We can see these tab stops in Microsoft Word by enabling the ruler via "View" -> "Show" -> "Ruler".
self.assertEqual(3, len(para.get_effective_tab_stops()))
# Any tab characters we add will make use of the tab stops on the ruler and may,
# depending on the tab leader's value, leave a line between the tab departure and arrival destinations.
para.append_child(aw.Run(doc=doc, text='\tTab 1\tTab 2\tTab 3'))
doc.save(file_name=ARTIFACTS_DIR + 'Paragraph.TabStops.docx')

See Also