本文整理汇总了Python中html.HTML.div方法的典型用法代码示例。如果您正苦于以下问题:Python HTML.div方法的具体用法?Python HTML.div怎么用?Python HTML.div使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类html.HTML
的用法示例。
在下文中一共展示了HTML.div方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_html_report
# 需要导入模块: from html import HTML [as 别名]
# 或者: from html.HTML import div [as 别名]
def create_html_report(topwords,top_index,Pi):
ht = HTML()
div = ht.div(align="center")
heading = div.h2(style="text-align:center")
subhead = div.h3(style="text-align:center")
# Creating the header
No_of_topics = len(topwords) - 1
No_of_clusters = top_index.shape[0]
head = "Topics : %d \n, Cluster : %d" %(No_of_topics,No_of_clusters)
heading(head)
# Creating the table
for i in range(top_index.shape[0]):
head_sub = div.h4(style="text-align:center")
head_sub("Top Topics in Cluster %d (%.5f)" %(i+1,Pi[i]))
t = div.table(align="center",border="2",cellpadding="12",cellspacing="0",width="80%")
tb = t.tbody()
tr = tb.tr(style="text-align:center")
tr.th("Alpha")
tr.th("Top Words")
ind_alpha_index = top_index[i]
for index in ind_alpha_index:
tr = tb.tr(style="text-align:center")
alpha_val = '%.5f' %index[1]
tr.td(alpha_val)
tr.td(topwords[int(index[0])])
return(ht)
示例2: Chart
# 需要导入模块: from html import HTML [as 别名]
# 或者: from html.HTML import div [as 别名]
class Chart(object):
"""
Create and modify a chart.
Parameters
----------
name : str
The name of the chart. This will be the id of the div that holds the chart. Therefore no two charts in the
same document should have the same name.
local_jquery : str
Path to a local version of jquery. If not provided, one hosted on a CDN is used.
**Default:** None
local_requirejs : str
Path to a local version of requirejs. If not provided, one hosted on a CDN is used.
**Default:** None
local_d3_js : str
Path to a local version of d3js. If not provided, one hosted on a CDN is used.
**Default:** None
local_c3_js : str
Path to a local version of c3js. If not provided, one hosted on a CDN is used.
**Default:** None
local_c3_css : str
Path to a local version of c3's css. If not provided, one hosted on a CDN is used.
**Default:** None
Attributes
----------
axes : c3py.axes.Axes
data : c3py.data.Data
grid : c3py.grid.Grid
legend : c3py.legend.Legend
tooltip : c3py.tooltip.Tooltip
regions : c3py.regions.Regions
point : c3py.point.Point
size : c3py.size.Size
padding : c3py.padding.Padding
"""
def __init__(self, name, local_jquery=None, local_requirejs=None, local_d3_js=None, local_c3_js=None,
local_c3_css=None):
super(Chart, self).__init__()
self.chart_html = HTML()
self.name = name
self.c3_css_path = local_c3_css or 'https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css'
self.jquery_path = local_jquery or 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js'
self.requirejs_path = local_requirejs or \
'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.17/require.min.js'
self.d3_js_path = local_d3_js or 'http://d3js.org/d3.v3.min'
self.c3_js_path = local_c3_js or 'https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min'
self.chart_html.div('', id=self.name)
self.chart_html.link('', href=self.c3_css_path, rel='stylesheet', type='text/css')
self.chart_html.script('', src=self.jquery_path)
self.chart_html.script('', src=self.requirejs_path)
self.requirejs_config = {
'paths': {
'c3': self.c3_js_path,
'd3': self.d3_js_path,
}
}
self.axes = Axes()
self.data = Data(self.axes)
self.grid = Grid(self.axes)
self.legend = Legend()
self.tooltip = Tooltip()
self.regions = Regions(self.axes)
self.point = Point()
self.size = Size()
self.padding = Padding()
#.........这里部分代码省略.........
示例3: HTML
# 需要导入模块: from html import HTML [as 别名]
# 或者: from html.HTML import div [as 别名]
MEDIA_DIR = "media"
IMGS_DIR = "pics"
THUMBS_DIR = "thumbs"
THUMB_SIZE = (320, 320)
imgs_path = os.path.join(PUBLIC_DIR, MEDIA_DIR, IMGS_DIR)
html_imgs_path = os.path.join(MEDIA_DIR, IMGS_DIR)
h = HTML()
i = 0
for root, dirs, files in os.walk(imgs_path):
for img_file in files:
if img_file != ".DS_Store" and img_file.endswith("_thumb.jpg"):
if i % 8 == 0:
row = h.div(klass="row")
cell = row.div(klass="col-1-8 image-cell")
cell.img(src=str(os.path.join(html_imgs_path, img_file)))
i += 1
with open("photos-section-partial.html", "w") as photos_section:
photos_section.write(str(h))
# # Code to generate thumbnails.
# for root, dirs, files in os.walk(imgs_path):
# for img_file in files:
# if img_file == ".DS_Store":
# continue
# else:
# im = Image.open(os.path.join(imgs_path, img_file))
# im.thumbnail(THUMB_SIZE, Image.ANTIALIAS)