MCPcopy Index your code
hub / github.com/python-openxml/python-docx / add_style

Method add_style

src/docx/styles/styles.py:55–65  ·  view source on GitHub ↗

Return a newly added style object of `style_type` and identified by `name`. A builtin style can be defined by passing True for the optional `builtin` argument.

(self, name, style_type, builtin=False)

Source from the content-addressed store, hash-verified

53 return len(self._element.style_lst)
54
55 def add_style(self, name, style_type, builtin=False):
56 """Return a newly added style object of `style_type` and identified by `name`.
57
58 A builtin style can be defined by passing True for the optional `builtin`
59 argument.
60 """
61 style_name = BabelFish.ui2internal(name)
62 if style_name in self:
63 raise ValueError("document already contains style '%s'" % name)
64 style = self._element.add_style_of_type(style_name, style_type, builtin)
65 return StyleFactory(style)
66
67 def default(self, style_type: WD_STYLE_TYPE):
68 """Return the default style for `style_type` or |None| if no default is defined

Callers 4

when_I_call_add_styleFunction · 0.80
add_style_of_typeMethod · 0.80

Calls 3

StyleFactoryFunction · 0.90
ui2internalMethod · 0.80
add_style_of_typeMethod · 0.80