shao
This commit is contained in:
parent
486abc09c9
commit
e10e8b3e33
|
@ -1,5 +1,6 @@
|
|||
import plotly.graph_objects as go
|
||||
from nicegui import ui
|
||||
import pandas as pd
|
||||
from random import random
|
||||
|
||||
|
||||
|
@ -21,7 +22,17 @@ def add_trace():
|
|||
ui.button('Add trace', on_click=add_trace)
|
||||
|
||||
|
||||
df = pd.DataFrame(columns=['x', 'y', 'z'])
|
||||
table = ui.table.from_pandas(df).classes('max-h-40')
|
||||
def add_to_dataframe():
|
||||
|
||||
# 将新行添加到DataFrame
|
||||
new_row = {'x': x.value, 'y': y.value, 'z': z.value}
|
||||
global df # 使用global声明,以便在函数内部修改全局变量df
|
||||
df = df.append(new_row, ignore_index=True)
|
||||
# 更新表格显示
|
||||
|
||||
table = ui.table.from_pandas(df).classes('max-h-40')
|
||||
|
||||
|
||||
ui.button('Add to DataFrame', on_click=add_to_dataframe)
|
||||
ui.run()
|
Loading…
Reference in New Issue