put_table如何设置表格列宽? #433
vonandrew
started this conversation in
Feature request
Replies: 1 comment
-
我对前端不太熟,自己摸索使用样式函数实现如下:
示例代码如下 table = []
headers = ['1st col', '2nd col']
data = [['1st row', 'china daily'],
['2nd row', "Tesla Inc is expected to produce more vehicles in China than in the United States, \
as its Shanghai plant has become the carmaker's largest manufacturing facility across the globe."]]
cols_size = [100, 200]
th = []
for i, h in enumerate(headers):
th.append(put_text(h).style(f"width:{cols_size[i]}px"))
table.append(th)
for i in range(len(data)):
tr = []
for j in range(len(data[0])):
cell = data[i][j]
cell_widget = put_text(f"{cell}")
tr.append(cell_widget)
table.append(tr)
put_table(table).style(f"width: 400px; table-layout: fixed; word-wrap: normal") 在pywebio文档中没找到对表格行和单元格单独的输出函数,不知怎么对表格行和单元格的样式(比如底色、边框、外边距和内边距等)进行设置,有知道的大佬请告知,感谢。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
使用put_grid可以设置每列宽度。请教:
非常感谢
Beta Was this translation helpful? Give feedback.
All reactions