当前位置: 首页>>代码示例>>Python>>正文


Python style.Style类代码示例

本文整理汇总了Python中odf.style.Style的典型用法代码示例。如果您正苦于以下问题:Python Style类的具体用法?Python Style怎么用?Python Style使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Style类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_percentage

    def test_percentage(self):
        """ Test that an automatic style can refer to a PercentageStyle as a datastylename """
        doc = OpenDocumentSpreadsheet()
        nonze = PercentageStyle(name='N11')
        nonze.addElement(Number(decimalplaces='2', minintegerdigits='1'))
        nonze.addElement(Text(text='%'))
        doc.automaticstyles.addElement(nonze)
        pourcent = Style(name='pourcent', family='table-cell', datastylename='N11')
        pourcent.addElement(ParagraphProperties(textalign='center'))
        pourcent.addElement(TextProperties(attributes={'fontsize':"10pt",'fontweight':"bold", 'color':"#000000" }))
        doc.automaticstyles.addElement(pourcent)

        table = Table(name='sheet1')
        tr = TableRow()
        tc = TableCell(formula='=AVERAGE(C4:CB62)/2',stylename='pourcent', valuetype='percentage')
        tr.addElement(tc)
        table.addElement(tr)
        doc.spreadsheet.addElement(table)
        doc.save("TEST.odt")
        self.saved = True
        d = load("TEST.odt")
        result = d.contentxml()
        self.assertNotEqual(-1, result.find(u'''<number:percentage-style'''))
        self.assertNotEqual(-1, result.find(u'''style:data-style-name="N11"'''))
        self.assertNotEqual(-1, result.find(u'''style:name="pourcent"'''))
开发者ID:agiacomolli,项目名称:odfpy,代码行数:25,代码来源:testdatastyles.py

示例2: colwidth

 def colwidth(self, width):
     if width not in self._widthstyles:
         w = Style(name="W{}".format(width), family="table-column")
         w.addElement(TableColumnProperties(columnwidth=width))
         self.doc.automaticstyles.addElement(w)
         self._widthstyles[width] = w
     return self._widthstyles[width]
开发者ID:sde1000,项目名称:quicktill,代码行数:7,代码来源:spreadsheets.py

示例3: generate_ods

def generate_ods(data):
    """
    Generate a ODS file.
    :param data: list-like of dict with the data.
    :return:
    """
    doc = OpenDocumentSpreadsheet()
    table = Table()
    tr = TableRow()
    colautowidth = Style(name="co1", family="table-column")
    colautowidth.addElement(TableColumnProperties(useoptimalcolumnwidth=True))
    doc.automaticstyles.addElement(colautowidth)
    for column in data[0].keys():
        table.addElement(TableColumn(stylename=colautowidth))
        tc = TableCell(valuetype="string", value=column)
        tc.addElement(P(text=column))
        tr.addElement(tc)
    table.addElement(tr)
    for row in data:
        tr = TableRow()
        for column in row.keys():
            tc = TableCell(valuetype="string", value=row[column])
            tc.addElement(P(text=row[column]))
            tr.addElement(tc)
        table.addElement(tr)
    file = os.path.join(tempfile.gettempdir(), 'SIGE' +
                        datetime.now().strftime('%Y%m%d%H%M%S%f') + '.ods')
    doc.spreadsheet.addElement(table)
    print(doc.automaticstyles.childNodes[0].attributes)
    doc.save(file)
    return file
开发者ID:C-Element,项目名称:SigeLib,代码行数:31,代码来源:files.py

示例4: __handleFrameStyleRotated

 def __handleFrameStyleRotated(self, text_data):
     style_name = "box%s%s%s%s%sRotated" % (
         text_data.face,
         text_data.size,
         text_data.line_space,
         text_data.letter_space,
         text_data.justification,
     )
     if not style_name in self.font_styles:
         frame_style = Style(name=style_name, family="paragraph")
         frame_style.addElement(
             ParagraphProperties(
                 linespacing="%spt" % text_data.line_space, textalign=self.convertTextAlign(text_data.justification)
             )
         )
         frame_style.addElement(
             TextProperties(
                 letterspacing="%spt" % text_data.letter_space,
                 fontstyle=self.convertFontStyle(text_data.style),
                 fontweight=self.convertFontWeight(text_data.weight),
                 fontsize="%spt" % text_data.size,
                 fontfamily=str(text_data.face),
             )
         )
         self.document.automaticstyles.addElement(frame_style)
         self.font_styles.append(style_name)
     return style_name
开发者ID:ZhangXinNan,项目名称:ocrfeeder,代码行数:27,代码来源:documentGeneration.py

示例5: _add_headerstyle

 def _add_headerstyle(self):
     header = Style(name="ColumnHeader", family="table-cell")
     header.addElement(
         ParagraphProperties(textalign="center"))
     header.addElement(
         TextProperties(fontweight="bold"))
     self.doc.styles.addElement(header)
     return header
开发者ID:sde1000,项目名称:quicktill,代码行数:8,代码来源:spreadsheets.py

示例6: addParagraphStyle

 def addParagraphStyle(self, id, name, paragraph_properties={}, text_properties={}):
     """  """
     style = Style(name=name, family="paragraph")
     if len(paragraph_properties) > 0:
         style.addElement(ParagraphProperties(**paragraph_properties))
     if len(text_properties) > 0:
         style.addElement(TextProperties(**text_properties))
     setattr(self, id, style)
     self.document.styles.addElement(style)
开发者ID:Guts,项目名称:Metadator,代码行数:9,代码来源:test_md2odt_old.py

示例7: newPage

 def newPage(self, page_data):
     master_name = self.__handlePageMaster(page_data)
     page_style_name = "%sPage" % master_name
     if not page_style_name in self.page_styles:
         page_style = Style(name=page_style_name, family="paragraph", masterpagename=master_name)
         page_style.addElement(ParagraphProperties(breakbefore="page"))
         self.document.automaticstyles.addElement(page_style)
     new_page = P(stylename=page_style_name)
     self.document.text.addElement(new_page)
     return new_page
开发者ID:ZhangXinNan,项目名称:ocrfeeder,代码行数:10,代码来源:documentGeneration.py

示例8: setup

 def setup(self):
     odt = self.generator
     s = odt.styles
     h1s = Style(name="Heading 1", family="paragraph")
     h1s.addElement(
          TextProperties(
              attributes={'fontsize': "24pt",
                          'fontweight': "bold"}
                        )
                   )
     s.addElement(h1s)
     self.h1s = h1s
开发者ID:ocarneiro,项目名称:pylotex,代码行数:12,代码来源:odt.py

示例9: __setDefaultStyle

    def __setDefaultStyle(self):
        DefaultStyle = Style(name="Standard", family='paragraph')
        DefaultStyle.addElement(TextProperties(
            fontfamily='FreeSans',
            fontsize='10pt'))
        DefaultStyle.addElement(ParagraphProperties(
            margintop='0.423cm',
            marginbottom='0.212cm'))
        self.__doc.styles.addElement(DefaultStyle)

        ''' Text Body '''
        txt = Style(name='text_20_body', family='paragraph', parentstylename='Standard')
        self.__doc.styles.addElement(txt)
开发者ID:WillBickerstaff,项目名称:sundial,代码行数:13,代码来源:odt.py

示例10: border_spices

def border_spices(an_odt, a_spice, a_font):
	## graphic
	border_stylename = a_spice + "border_style"
	border_graphic_style = Style(name=border_stylename, family="graphic")
	#href = an_odt.addPicture(a_spice + ".jpg")
	#if a_spice == "kristallen":
	#	border_graphic_properties = GraphicProperties(border="0.5mm double #000000")
	#elif a_spice == "roze":
	#	border_graphic_properties = GraphicProperties(border="0.5mm double #000000")
	#else:
	#	border_graphic_properties = GraphicProperties(border="0.5mm double #000000")
	border_graphic_properties = GraphicProperties(border="0.5mm double #000000")
	border_graphic_style.addElement(border_graphic_properties)
	border_beehive = beehive(an_odt, border_graphic_style,
							"273mm", "194mm", "-12mm", "-12mm", "1")
	border_frame = border_beehive["frame"]
	border_textbox = border_beehive["textbox"]

	## textgraph
	border_stylename = "emptygif"
	border_textgraph_style = Style(name=border_stylename, family="paragraph")
	border_text_props = TextProperties()
	border_textgraph_style.addElement(border_text_props)
	border_paragraph_props = ParagraphProperties()
	border_textgraph_style.addElement(border_paragraph_props)
	an_odt.styles.addElement(border_textgraph_style)

	text_unit(an_odt, border_textgraph_style, u"", border_textbox)

	an_odt.text.addElement(border_frame)
开发者ID:osp,项目名称:osp.work.openbaar-schrijver,代码行数:30,代码来源:dingbat_spices.py

示例11: image_spices

def image_spices(an_odt, a_spice, a_font):
	## graphic
	image_stylename = a_spice + "frame_style"
	image_graphic_style = Style(name=image_stylename, family="graphic")
	href = an_odt.addPicture(a_spice + ".jpg")
	if a_spice == "chocolade":
		backgroundimage = BackgroundImage(href=href, position="top left", repeat="no")
	elif a_spice == "koraal":
		backgroundimage = BackgroundImage(href=href, position="bottom right", repeat="no")
	else:
		backgroundimage = BackgroundImage(href=href, position="top left", repeat="repeat")
	image_graphic_properties = GraphicProperties(border="0.5mm double #000000")
	image_graphic_properties.addElement(backgroundimage)
	image_graphic_style.addElement(image_graphic_properties)
	image_beehive = beehive(an_odt, image_graphic_style,
							"273mm", "194mm", "-12mm", "-12mm", "1")
	image_frame = image_beehive["frame"]
	image_textbox = image_beehive["textbox"]

	## textgraph
	image_stylename = "emptygif"
	image_textgraph_style = Style(name=image_stylename, family="paragraph")
	image_text_props = TextProperties()
	image_textgraph_style.addElement(image_text_props)
	image_paragraph_props = ParagraphProperties()
	image_textgraph_style.addElement(image_paragraph_props)
	an_odt.styles.addElement(image_textgraph_style)

	text_unit(an_odt, image_textgraph_style, u"", image_textbox)

	an_odt.text.addElement(image_frame)
开发者ID:osp,项目名称:osp.work.openbaar-schrijver,代码行数:31,代码来源:image_spices.py

示例12: _create_style

def _create_style(name, family=None, **kwargs):
    """Helper function for creating a new style."""
    if family == 'paragraph' and 'marginbottom' not in kwargs:
        kwargs['marginbottom'] = '.5cm'
    style = Style(name=name, family=family)
    # Extract paragraph properties.
    kwargs_par = {}
    keys = sorted(kwargs.keys())
    for k in keys:
        if 'margin' in k:
            kwargs_par[k] = kwargs.pop(k)
    style.addElement(TextProperties(**kwargs))
    if kwargs_par:
        style.addElement(ParagraphProperties(**kwargs_par))
    return style
开发者ID:hrishikeshvganu,项目名称:ipymd,代码行数:15,代码来源:opendocument.py

示例13: add_title_page

	def add_title_page(self, odt, title):
		# Requirements for <project name>
		# <project description>
		#
		# Author: <stakeholder name>
		# <date>
		#
		# <document description>
		# Title
		titlestyle = Style(name="TitleStyle",family="text")
		titlestyle.addElement(TextProperties(attributes={'fontweight':"bold", 'fontsize':'36pt'}))
		odt.automaticstyles.addElement(titlestyle)
		titlespan = Span(stylename=titlestyle, text=_('Requirements for "%s"') % title)
		p = P(text='')
		p.addElement(titlespan)
		odt.text.addElement(p)
开发者ID:oliverfields,项目名称:reqy,代码行数:16,代码来源:GenRequirementList.py

示例14: copyStyle

def copyStyle(style, autoStylesCache):
    autoStylesCache['lastIndex'] = autoStylesCache['lastIndex'] + 1
    cloneName = 'ce%d' % autoStylesCache['lastIndex']
    logger.debug('copy style : %s -> %s' % (style.getAttrNS(STYLENS, 'name'), cloneName))
    
    # Create the clone
    cloneStyle = Style(name=cloneName,family="table-cell")
    for node in style.childNodes:
        newNode = copy.copy(node)
        newNode.parentNode = None
        cloneStyle.appendChild(newNode)
    
    # Save the clone into the cache
    autoStylesCache['root'].addElement(cloneStyle)
    autoStylesCache['styles'][cloneName] = cloneStyle
    
    return cloneStyle
开发者ID:CEDAR-project,项目名称:Integrator,代码行数:17,代码来源:recolor.py

示例15: add_attribute_row

	def add_attribute_row(self, table, key, value):
		""" Add a two cell row to the table """
		boldstyle = Style(name="Bold",family="text")
		boldstyle.addElement(TextProperties(attributes={'fontweight':"bold"}))

		title_span = Span(stylename=boldstyle, text=key)
		pt = P(text='')
		pt.addElement(title_span)

		tr = TableRow()
		tc = TableCell(valuetype='string')
		tc.addElement(pt)
		tr.addElement(tc)
		tc = TableCell(valuetype='string')
		tc.addElement(P(text=value))
		tr.addElement(tc)
		table.addElement(tr)
开发者ID:oliverfields,项目名称:reqy,代码行数:17,代码来源:GenRequirementList.py


注:本文中的odf.style.Style类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。