def chart_css(fill, style, color): '''Function to add opacity to charts.''' fill.solid() pix_to_inch = 100000 fill.fore_color.rgb = RGBColor.from_string(utils.convert_color_code(color)) solid_fill = fill.fore_color._xFill alpha = OxmlElement('a:alpha') alpha.set('val', '%d' % (pix_to_inch * style.get('opacity', 1.0))) solid_fill.srgbClr.append(alpha) return fill
def fill_opacity(fill: FillFormat, val: Union[int, float, None]) -> None: '''Set the FillFormat opacity to a number''' if fill.type != MSO_FILL.SOLID: raise ValueError('Cannot set opacity: %r on non-solid fill type %r' % (val, fill.type)) for tag in ('hslClr', 'sysClr', 'srgbClr', 'prstClr', 'scrgbClr', 'schemeClr'): color = fill._xPr.find('.//' + qn('a:%s' % tag)) if color is not None: alpha = color.find(qn('a:alpha')) if alpha is None: alpha = OxmlElement('a:alpha') color.append(alpha) alpha.set('val', ST_Percentage.convert_to_xml(val)) break
def get_or_add_link(shape, type, event): # el is the lxml element of the shape. Can be ._element or ._run el = getattr(shape, conf['link-attrs'][type]['el']) # parent is the container inside which we insert the link. Can be p:cNvPr or a:rPr parent = el.find('.//' + conf['link-attrs'][type]['tag'], _nsmap) # Create link if required. (Else preserve all attributes one existing link, like tooltip) link = parent.find(qn('a:%s' % event)) if link is None: link = OxmlElement('a:%s' % event) parent.insert(0, link) return link
def SubElement(self, parent, tagname, **kwargs): # Para personalizar as características do slide element = OxmlElement(tagname) element.attrib.update(kwargs) parent.append(element) return element
def _new_off(self): off = OxmlElement("a:off") off.x = 0 off.y = 0 return off
def _new_ext(self): ext = OxmlElement("a:ext") ext.cx = 0 ext.cy = 0 return ext
def SubElement(parent, tagname, **kwargs): element = OxmlElement(tagname) element.attrib.update(kwargs) parent.append(element) return element
def sub_element(parent, tagname, **kwargs): # necessary for table formatting element = OxmlElement(tagname) element.attrib.update(kwargs) parent.append(element) return element