我想在每个散景Tab(散景面板)内有几个表
但是,表格水平连接在一起,我找不到很好地展示它们的方法。我使用了一个愚蠢的Div作为快速解决方案,但它创造了太多的空间,甚至是宽度= 1的Div。我该如何实现这一目标?这是我的代码:
from bokeh.models.widgets import Panel, Tabs, TableColumn,DataTable, Div
import numpy as np
from bokeh.io import output_notebook, show
from bokeh.models import ColumnDataSource
from bokeh.layouts import row, column, layout
output_notebook()
columns = [
TableColumn(field="A", title="A"),
TableColumn(field="B", title="B"),
TableColumn(field="C", title="C"),
TableColumn(field="D", title="D"),]
data1 = {"A":np.random.randint(23, 89, 10),
"B": np.random.randint(23, 89, 10),
"C": np.random.randint(23, 89, 10),
"D": np.random.randint(23, 89, 10)}
source1 = ColumnDataSource(data1)
p1 = DataTable(source=source1, columns=columns, width=300, height=200,editable=True)
data2 = {"A":np.random.randint(23, 89, 10),
"B": np.random.randint(23, 89, 10),
"C": np.random.randint(23, 89, 10),
"D": np.random.randint(23, 89, 10)}
source2 = ColumnDataSource(data2)
p2 = DataTable(source=source2, columns=columns, width=300, height=200,editable=True)
data3 = {"A":np.random.randint(23, 89, 10),
"B": np.random.randint(23, 89, 10),
"C": np.random.randint(23, 89, 10),
"D": np.random.randint(23, 89, 10)}
source3 = ColumnDataSource(data3)
p3 = DataTable(source=source3, columns=columns, width=300, height=200,editable=True)
dumbdiv = Div(text=""" """,
width=1, height=20)
l1 = layout([[p1, p2], [p3]], sizing_mode='fixed')
# l1 = layout([[p1, dumbdiv, p2]], sizing_mode='fixed')
tab1 = Panel(child=l1, title="Three Tables")
tabs = Tabs(tabs=[tab1],sizing_mode='scale_width')
show(tabs)
这是结果:(第一个表的滚动条没有显示;我希望第一行的表之间有一些空格)
Div()的问题是两个数据表之间可能存在相当大的差距 - 远远超过需要。我认为使用Spacer看起来更好
row2 = row(p1, Spacer(width=600, height=10), p2)
l1 = layout([row2], sizing_mode='fixed')