本文整理汇总了Python中nevow.tags.div函数的典型用法代码示例。如果您正苦于以下问题:Python div函数的具体用法?Python div怎么用?Python div使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了div函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_footer
def render_footer(self, context, data):
return tags.p() [
tags.div()['Lumen is running on port %s' % lumen.config['port']],
tags.div()[
tags.a(href='http://github.com/unsouled/lumen')['Github']
]
]
示例2: render_content
def render_content(self, ctx, data):
request = inevow.IRequest(ctx)
ctx.fillSlots('header_bar', self.anon_header)
ctx.fillSlots('top_bar', T.div(id="top_bar"))
ctx.fillSlots('main_content', loaders.stan(T.div(id="manager_hook")))
return ctx.tag
示例3: gotProducts
def gotProducts(products):
htmlblock = []
for n,product in enumerate(products):
column = divmod(n,3)[1]+1
name = product.code
title = product.title
shortDescription = product.summary
imgsrc='/system/ecommerce/%s/mainImage?size=190x300&sharpen=1.0x0.5%%2b0.8%%2b0.1'%product.id
html = T.div(class_='category c%s'%column)[
T.a(href=url.here.child(name))[
T.img(src=imgsrc,width=190),T.span(class_='mbf-item')['#gallery %s'%product.code]
],
T.h4[
T.a(href=url.here.child(name))[
title
]
],
T.p[
T.a(href=url.here.child(name))[
shortDescription
]
]
]
htmlblock.append(html)
# Group the output into threes
if column == 3:
out = htmlblock
htmlblock = []
yield T.div(class_="threecolumnleft clearfix")[ out ]
# and then yield anything left over if the last item wasn't at the end of a row
if column != 3:
yield T.div(class_="threecolumnleft clearfix")[ htmlblock ]
示例4: rend
def rend(self, *junk):
(l, middle, r) = self.extract.inContext()
return tags.div(class_='extract-container')[
l,
tags.div(class_='extract-text')[
tags.span[middle]],
r]
示例5: test_url
def test_url(self):
"""
An L{URL} object is flattened to the appropriate representation of
itself, whether it is the child of a tag or the value of a tag
attribute.
"""
link = URL.fromString("http://foo/fu?bar=baz&bar=baz#quux%2f")
self.assertStringEqual(
self.flatten(link),
"http://foo/fu?bar=baz&bar=baz#quux%2F")
self.assertStringEqual(
self.flatten(div[link]),
'<div>http://foo/fu?bar=baz&bar=baz#quux%2F</div>')
self.assertStringEqual(
self.flatten(div(foo=link)),
'<div foo="http://foo/fu?bar=baz&bar=baz#quux%2F"></div>')
self.assertStringEqual(
self.flatten(div[div(foo=link)]),
'<div><div foo="http://foo/fu?bar=baz&bar=baz#quux%2F"></div>'
'</div>')
link = URL.fromString("http://foo/fu?%2f=%7f")
self.assertStringEqual(
self.flatten(link),
"http://foo/fu?%2F=%7F")
self.assertStringEqual(
self.flatten(div[link]),
'<div>http://foo/fu?%2F=%7F</div>')
self.assertStringEqual(
self.flatten(div(foo=link)),
'<div foo="http://foo/fu?%2F=%7F"></div>')
示例6: test_applicationNavigationChildren
def test_applicationNavigationChildren(self):
"""
The L{applicationNavigation} renderer should fill the 'subtabs' slot
with copies of the 'subtab' pattern for each tab, if that pattern is
present. (This is only tested to one level of depth because we
currently only support one level of depth.)
"""
tag = self._renderAppNav(
[
webnav.Tab("alpha", 123, 0),
webnav.Tab("beta", 234, 0, children=[webnav.Tab("gamma", 345, 0), webnav.Tab("delta", 456, 0)]),
],
tags.span[
tags.div(pattern="app-tab"),
tags.div(pattern="tab-contents"),
tags.div(pattern="subtab"),
tags.div(pattern="subtab-contents", class_="subtab-contents-class"),
],
)
navTags = list(tag.slotData["tabs"])
self.assertEqual(len(navTags), 2)
alpha, beta = navTags
self.assertEqual(alpha.slotData["subtabs"], [])
self.assertEqual(len(beta.slotData["subtabs"]), 2)
subtab1 = beta.slotData["subtabs"][0]
self.assertEqual(subtab1.slotData["name"], "gamma")
self.assertEqual(subtab1.slotData["href"], "/link/345")
self.assertEqual(subtab1.slotData["tab-contents"].attributes["class"], "subtab-contents-class")
subtab2 = beta.slotData["subtabs"][1]
self.assertEqual(subtab2.slotData["name"], "delta")
self.assertEqual(subtab2.slotData["href"], "/link/456")
self.assertEqual(subtab2.slotData["tab-contents"].attributes["class"], "subtab-contents-class")
示例7: calculateDefaultSkin
def calculateDefaultSkin(self, context):
if self.isGrouped:
frm = tags.invisible
butt = ""
fld = tags.invisible
else:
frm = tags.form(
id=slot("form-id"),
name=slot("form-id"),
action=slot("form-action"),
method="post",
enctype="multipart/form-data",
**{"accept-charset": "utf-8"}
)
butt = slot("form-button")
fld = tags.fieldset[tags.input(type="hidden", name="_charset_")]
## Provide default skin since no skin was provided for us.
context.tag.clear()[
frm[
fld[
tags.legend(_class="freeform-form-label")[slot("form-label")],
tags.div(_class="freeform-form-description")[slot("form-description")],
tags.div(_class="freeform-form-error")[slot("form-error")],
slot("form-arguments"),
butt,
]
]
]
示例8: visit_cmsimage_node
def visit_cmsimage_node(self, node):
maxwidth=node.attributes['maxwidth']
maxheight=node.attributes['maxheight']
if maxwidth is None or maxheight is None:
tag = T.img(src=self.systemURL.child('assets').child( node.attributes['id'] ))
else:
tag = T.img(src=self.systemURL.child('assets').child( node.attributes['id'] ).add('size','%sx%s'%(maxwidth,maxheight)))
if node.attributes['alt']:
tag = tag(alt=node.attributes['alt'])
if node.attributes['title']:
tag = tag(title=node.attributes['title'])
if node.attributes['cssclass']:
tag = tag(class_=node.attributes['cssclass'])
if node.attributes['href']:
tag = T.a(href=node.attributes['href'])[ tag ]
if node.attributes['caption']:
tag = T.div(class_='cmsimage')[tag,T.p[node.attributes['caption']]]
else:
tag = T.div(class_='cmsimage')[tag]
html = flat.flatten(tag)
self.body.append(html)
示例9: divBar
def divBar(text, width, fraction, barColor):
fraction = min(1, max(0, fraction))
sp = T.raw(" ")
return T.div(class_="bar", style="width: %spx;" % width)[
T.div(class_="fill", style="width: %dpx; background: %s" % (width * fraction, barColor))[sp],
T.div(class_="txt")[text],
sp,
]
示例10: gotAll
def gotAll(items,categories,products):
categoryCMSItems = {}
for item in items:
i = item.getProtectedObject()
categoryCMSItems[i.name] = i
categoryCMSItemMainImage = {}
categoryCMSItemCode = {}
for categoryCMSItem in categoryCMSItems.values():
category = categoryCMSItem.name
for product in products:
if u'gallery.%s'%category in product.categories:
match = product
categoryCMSItemMainImage[categoryCMSItem.name] = match.id
categoryCMSItemCode[categoryCMSItem.name] = match.code
break
htmlblock = []
for n, category in enumerate(categories.children):
name = category.textid
categoryCMSItem = categoryCMSItems.get(name,None)
column = divmod(n,3)[1]+1
try:
title = categoryCMSItem.title
shortDescription = categoryCMSItem.shortDescription
except AttributeError:
title = category.label
shortDescription = ''
try:
imgsrc='/system/ecommerce/%s/mainImage?size=190x300&sharpen=1.0x0.5%%2b0.7%%2b0.1'%categoryCMSItemMainImage[name]
except KeyError:
imgsrc='/skin/images/spacer.gif'
html = T.div(class_='category c%s'%column)[
T.a(href=url.here.child(name))[
T.img(src=imgsrc,width=190),T.span(class_='mbf-item')['#gallery %s'%categoryCMSItemCode[name]]
],
T.h4[
T.a(href=url.here.child(name))[
title
]
],
T.p[
T.a(href=url.here.child(name))[
shortDescription
]
]
]
htmlblock.append(html)
# Group the output into threes
if column == 3:
out = htmlblock
htmlblock = []
yield T.div(class_="threecolumnleft clearfix")[ out ]
# and then yield anything left over if the last item wasn't at the end of a row
if column != 3:
yield T.div(class_="threecolumnleft clearfix")[ htmlblock ]
示例11: getWidgetDocument
def getWidgetDocument(self):
"""
Return part of a document which contains some explicitly sized
elements. The client portion of this test will retrieve them by their
class value and assert things about their size.
"""
return tags.div[
tags.div(class_='foo', style='height: 126px; width: 1px'),
tags.div(class_='bar', style='padding: 1px 2px 3px 4px; height: 12px; width: 70px')]
示例12: renderImmutable
def renderImmutable(self, ctx, key, args, errors):
value = iformal.IStringConvertible(self.original).fromType(args.get(key))
if value:
value=T.xml(value)
else:
value=''
return T.div(id=key, class_="readonly-textarea-container") [
T.div(class_='readonly-textarea readonly')[value]
]
示例13: render_body
def render_body(self, ctx, data):
for j in range(self.maxNodes // self.maxDepth):
top = t = tags.div()
for i in range(self.maxDepth):
m = tags.div()
t[m]
t = m
t[InitializationBenchmark(self)]
yield top
示例14: render_middle
def render_middle(self, context, data):
yield T.div(render=T.directive('trail'), data=data.get_ancestry())
yield T.h1(class_='main-heading')[data.title]
yield T.div(render=T.directive('items'), data=data.get_subdirs())
yield T.div(render=T.directive('rst'))
yield T.div(render=T.directive('items'), data=data.get_items())
示例15: progressBar
def progressBar(self, ctx, data):
name = data.get('name', 'theProgressBar')
percent = data.get('percent', 0)
yield t.div(class_='progressBar', id_=str(name))[
t.div(class_ ='progressBarDiv', style='width: %i%%'%percent) ]
yield t.script(type='text/javascript')[
component[name].init('new ProgressBar(%r)'%name),
#component[name].setPercent(percent)
]