本文整理汇总了Python中element.Element.append方法的典型用法代码示例。如果您正苦于以下问题:Python Element.append方法的具体用法?Python Element.append怎么用?Python Element.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类element.Element
的用法示例。
在下文中一共展示了Element.append方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from element import Element [as 别名]
# 或者: from element.Element import append [as 别名]
class Hyperlink :
_hyperlink = ''
_rel_id = ''
_url = ''
def __init__(self, text, rel_id, url, anchor=None) :
self._rel_id = rel_id
self._url = url
if anchor is None :
self._hyperlink = Element().createElement('hyperlink', attr={'rel_id' : 'rId' + rel_id})
else :
self._hyperlink = Element().createElement('hyperlink', attr={'anchor' : anchor})
run = Element().createElement('r')
rPr = Element().createElement('rPr')
style = Element().createElement('rStyle', attr={'val' : 'Hyperlink'})
rPr.append(style)
run.append(rPr)
textEl = Element().createElement('t', text=text, attr={'space' : 'preserve'})
run.append(textEl)
self._hyperlink.append(run)
def get(self) :
return self._hyperlink
def getRelation(self) :
attr = {'TargetMode' : 'External', 'Type' : HYPERLINK_SCHEMA, 'Id' : 'rId' + self._rel_id, 'Target' : self._url}
rel = Element().createElement('Relationship', prefix=None, attr=attr)
return rel
示例2: __init__
# 需要导入模块: from element import Element [as 别名]
# 或者: from element.Element import append [as 别名]
def __init__(self, text='', style='NormalWeb', styles=None) :
self._styles = {
'bold' : False,
'italic' : False,
'underline' : False,
'uppercase' : False,
'color' : False,
'font' : False
}
if styles is not None :
for key, value in styles.items() :
self._styles[key] = value
#root element
self.para = Element().createElement('p')
#style element
pPr = Element().createElement('pPr')
self.para.append(pPr)
pPr.append(Element().createElement('pStyle', attr={'val' : style}))
#run and text element
run = Element().createElement('r')
self._prop = Element().createElement('rPr')
run.append(self._prop)
#set styles
self.setStyles()
textEl = Element().createElement('t', attr={'space' : 'preserve'})
textEl.text = text
run.append(textEl)
self.para.append(run)
示例3: __init__
# 需要导入模块: from element import Element [as 别名]
# 或者: from element.Element import append [as 别名]
def __init__(self, image, id, rel_id, width="100%", height="100%", url_id=None):
self._image = open(image)
image_name = basename(self._image.name).replace(" ", "-")
id = id
img = PILImage.open(self._image.name)
imgwidth = self.pixelToEmu(img.size[0])
imgheight = self.pixelToEmu(img.size[1])
width = (float(width.replace("%", "")) / 100) * imgwidth
height = (float(height.replace("%", "")) / 100) * imgheight
rel_id = rel_id
self._p = Element().createElement("p")
r = Element().createElement("r")
rPr = Element().createElement("rPr")
noProof = Element().createElement("noProof")
lang = Element().createElement("lang", attr={"eastAsia": "nl-NL"})
rPr.append(noProof)
rPr.append(lang)
drawing = Element().createElement("drawing")
inline = Element().createElement(
"inline", attr={"distT": "0", "distR": "0", "distL": "0", "distB": "0"}, prefix="wp", attrprefix=None
)
extend = Element().createElement(
"extent", attr={"cy": str(int(height)), "cx": str(int(width))}, prefix="wp", attrprefix=None
)
effectExtent = Element().createElement(
"effectExtent", attr={"l": "19050", "t": "0", "r": "0", "b": "0"}, prefix="wp", attrprefix=None
)
docPr = Element().createElement(
"docPr", attr={"id": str(id), "descr": image_name, "name": "Picture 0"}, prefix="wp", attrprefix=None
)
if url_id is not None:
a = Element().createElement("hlinkClick", attr={"rel_id": "rId" + str(url_id)}, prefix="a")
docPr.append(a)
cNvGraphicFramePr = Element().createElement("cNvGraphicFramePr", prefix="wp")
graphicFrameLocks = Element().createElement(
"graphicFrameLocks", attr={"noChangeAspect": "1"}, prefix="a", attrprefix=None
)
cNvGraphicFramePr.append(graphicFrameLocks)
graphic = Element().createElement("graphic", prefix="a")
graphicData = Element().createElement(
"graphicData",
attr={"uri": "http://schemas.openxmlformats.org/drawingml/2006/picture"},
prefix="a",
attrprefix=None,
)
pic = Element().createElement("pic", prefix="pic")
nvPicPr = Element().createElement("nvPicPr", prefix="pic")
cNvPr = Element().createElement("cNvPr", attr={"id": "0", "name": image_name}, prefix="pic", attrprefix=None)
cNvPicPr = Element().createElement("cNvPicPr", prefix="pic")
nvPicPr.append(cNvPr)
nvPicPr.append(cNvPicPr)
blipFill = Element().createElement("blipFill", prefix="pic")
blip = Element().createElement("blip", attr={"embed": "rId" + str(rel_id)}, prefix="a")
stretch = Element().createElement("stretch", prefix="a")
fillRect = Element().createElement("fillRect", prefix="a")
stretch.append(fillRect)
blipFill.append(blip)
blipFill.append(stretch)
spPr = Element().createElement("spPr", prefix="pic")
xfrm = Element().createElement("xfrm", prefix="a")
off = Element().createElement("off", attr={"y": "0", "x": "0"}, prefix="a", attrprefix=None)
ext = Element().createElement(
"ext", attr={"cy": str(int(height)), "cx": str(int(width))}, prefix="a", attrprefix=None
)
xfrm.append(off)
xfrm.append(ext)
prstGeom = Element().createElement("prstGeom", attr={"prst": "rect"}, prefix="a", attrprefix=None)
avLst = Element().createElement("avLst", prefix="a")
prstGeom.append(avLst)
spPr.append(xfrm)
spPr.append(prstGeom)
pic.append(nvPicPr)
pic.append(blipFill)
pic.append(spPr)
graphicData.append(pic)
graphic.append(graphicData)
inline.append(extend)
inline.append(effectExtent)
inline.append(docPr)
inline.append(cNvGraphicFramePr)
inline.append(graphic)
drawing.append(inline)
r.append(rPr)
r.append(drawing)
self._p.append(r)
示例4: addItem
# 需要导入模块: from element import Element [as 别名]
# 或者: from element.Element import append [as 别名]
def addItem(self, text, level = 0) :
p = Element().createElement('p')
pPr = Element().createElement('pPr')
p.append(pPr)
style = Element().createElement('pStyle', attr={'val' : 'ListParagraph'})
numPr = Element().createElement('numPr')
pPr.append(style)
pPr.append(numPr)
levels = Element().createElement('ilvl', attr={'val' : str(level)})
numId = Element().createElement('numId', attr={'val' : '1'})
numPr.append(levels)
numPr.append(numId)
run = Element().createElement('r')
p.append(run)
textEl = Element().createElement('t')
textEl.text = text
run.append(textEl)
self._list.append(p)