简体   繁体   English

使用HTML.py模块在python中为表格行着色

[英]coloring a table row in python using HTML.py module

htmlcode=HTML.table(table_data,header_row=['Check','Setup','status','Logs','Comment'],
            col_width=['30%','20%','20%','10%','30%'])

here i want to color the table header row with grey color. 在这里,我想用灰色为表格标题行上色。 as a beginner in this language i couldnt figure it out. 作为这种语言的初学者,我无法弄清楚。 here im using a HTML.py module 我在这里使用HTML.py模块

i got this module from http://www.decalage.info/en/python/html so pls help in coloring the header row. 我从http://www.decalage.info/zh-CN/python/html获得了此模块,因此请帮助为标题行着色。

You may specify a background color for the header row, by using a TableRow object instead of a list. 您可以使用TableRow对象而不是列表来为标题行指定背景色。 For example: 例如:

t = HTML.Table(header_row = HTML.TableRow(['x', 'square(x)', 'cube(x)'], bgcolor='yellow'))


Source : one of the comments on module page : http://www.decalage.info/en/python/html 来源:模块页面上的评论之一: http : //www.decalage.info/en/python/html

It doesn't look like you can change them via anything simple (only allows for per-cell additions w/ color change). 看起来您无法通过任何简单的方式更改它们(仅允许每单元添加颜色更改)。 I would suggest linking in a css file with some .th{background-color:orange;} stylings, or use another module that is more robust. 我建议使用某些.th {background-color:orange;}样式链接CSS文件,或使用其他更可靠的模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM