MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / style_shape_border

Function style_shape_border

utils/pptx_utils.py:1814–1854  ·  view source on GitHub ↗

Applies a border (line) style to a given shape, where line_style is a string corresponding to an MSO_LINE_DASH_STYLE enum value from python-pptx. Valid line_style strings (based on the doc snippet) are: ----------------------------------------------------------------- 'solid'

(shape, color=(30, 144, 255), thickness=2, line_style="square_dot")

Source from the content-addressed store, hash-verified

1812 bg_fill.fore_color.rgb = RGBColor(*rgb)
1813
1814def style_shape_border(shape, color=(30, 144, 255), thickness=2, line_style="square_dot"):
1815 """
1816 Applies a border (line) style to a given shape, where line_style is a
1817 string corresponding to an MSO_LINE_DASH_STYLE enum value from python-pptx.
1818
1819 Valid line_style strings (based on the doc snippet) are:
1820 -----------------------------------------------------------------
1821 'solid' -> MSO_LINE_DASH_STYLE.SOLID
1822 'round_dot' -> MSO_LINE_DASH_STYLE.ROUND_DOT
1823 'square_dot' -> MSO_LINE_DASH_STYLE.SQUARE_DOT
1824 'dash' -> MSO_LINE_DASH_STYLE.DASH
1825 'dash_dot' -> MSO_LINE_DASH_STYLE.DASH_DOT
1826 'dash_dot_dot' -> MSO_LINE_DASH_STYLE.DASH_DOT_DOT
1827 'long_dash' -> MSO_LINE_DASH_STYLE.LONG_DASH
1828 'long_dash_dot'-> MSO_LINE_DASH_STYLE.LONG_DASH_DOT
1829 -----------------------------------------------------------------
1830
1831 :param shape: pptx.shapes.base.Shape object to style
1832 :param color: A tuple (R, G, B) for the border color (default is (30, 144, 255))
1833 :param thickness: Border thickness in points (default is 2)
1834 :param line_style:String representing the line dash style; defaults to 'square_dot'
1835 """
1836 # Map our string keys to MSO_LINE_DASH_STYLE values from your doc snippet
1837 dash_style_map = {
1838 "solid": MSO_LINE_DASH_STYLE.SOLID,
1839 "round_dot": MSO_LINE_DASH_STYLE.ROUND_DOT,
1840 "square_dot": MSO_LINE_DASH_STYLE.SQUARE_DOT,
1841 "dash": MSO_LINE_DASH_STYLE.DASH,
1842 "dash_dot": MSO_LINE_DASH_STYLE.DASH_DOT,
1843 "dash_dot_dot": MSO_LINE_DASH_STYLE.DASH_DOT_DOT,
1844 "long_dash": MSO_LINE_DASH_STYLE.LONG_DASH,
1845 "long_dash_dot": MSO_LINE_DASH_STYLE.LONG_DASH_DOT
1846 }
1847
1848 line = shape.line
1849 line.width = Pt(thickness)
1850 line.color.rgb = RGBColor(*color)
1851
1852 # Default to 'solid' if the requested style isn't in dash_style_map
1853 dash_style_enum = dash_style_map.get(line_style.lower(), MSO_LINE_DASH_STYLE.SOLID)
1854 line.dash_style = dash_style_enum
1855
1856def get_visual_cues(name_to_hierarchy, identifier, poster_path='poster.pptx'):
1857 prs = pptx.Presentation(poster_path)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected