我正在尝试制作一个从 csv 文件中获取数据的交互式表格。但是当从服务器更新时,表格会不断闪烁。
我试过这个,但它不起作用。 https://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html?highlight=flickering#Flickering-and-jumping-output
这是演示代码。您可以在 Jupyter 笔记本中看到闪烁。
import pandas as pd
import plotly.graph_objects as go
import ipywidgets as widgets
from IPython.display import display
from ipywidgets import interact, interactive
def demo_table(row):
fig = go.Figure(data=[
go.Table(
header=dict(values=['Column1', 'Column2', 'Column3'],
line = dict(color='#7D7F80'),
fill = dict(color='#a1c3d1'),
align = ['left'] * 5),
cells=dict(values=[[1, 2],[3, 4],[5, 6]],
line = dict(color='#7D7F80'),
fill = dict(color='#EDFAFF'),
align = ['left'] * 5)
)
])
fig.show()
play = widgets.Play(
interval=1000,
value=0,
min=0,
max=100,
step=1,
description="Press play",
disabled=False
)
slider = widgets.IntSlider()
widgets.jslink((play, 'value'), (slider, 'value'))
display(widgets.HBox([play]))
interactive_plot=interactive(demo_table, row=slider)
output = interactive_plot.children[-1]
output.layout.height = '350px'
interactive_plot
谢谢。