admin管理员组文章数量:1131210
In my case, I have been trying to create a tools for finding data in db. However, when I'm trying to find new data, the old result is not replace by the new one, it likely add new result under the latest output.
The second problem is, when the data table found, it automatically open download box. But I just want it to show the "download" button, it just download if only I click the the "Download" button
Here is my code, pls help!
def testSubmit(userInput, dateInput):
print(f"UserInput: {userInput} --- dataType: {type(userInput)}")
print(f"dateStart: {dateInput} --- dataType: {type(dateInput)}")
dataTableTest = pd.read_csv('./assetsTest/dataTest.csv').drop("id_date", axis=1)
dataTableTest['date'] = dataTableTest['date'].apply(lambda x: pd.to_datetime(x).strftime("%d-%m-%Y"))
dataRecord = dataTableTest.copy() # .to_dict(orient='records')
dataBasicStat = dataTableTest.describe().reset_index()
def download_button(data):
data.to_excel(f'./tmp/{userInput}.xlsx')
ui.download(f'./tmp/{userInput}.xlsx')
ui.navigate.reload()
with table_rows_container:
ui.table.from_pandas(dataRecord, pagination=10)
ui.table.from_pandas(dataBasicStat, pagination=10)
with buttonContainer:
ui.button('Download', on_click = download_button(dataTableTest), color='secondary').classes('mt-4')
with figure_rows_container:
figureTest = go.Figure()
figureTest.add_trace(
go.Scatter(
x = dataTableTest['date'],
y = dataTableTest['VND=D1'],
mode = 'lines',
name = 'VND=D1'
)
)
ui.plotly(figureTest)
# Element UI
with ui.element('div') as buttonContainer:
ui.button('Find Data', on_click=lambda: testSubmit(userInput.value, expectDateRange.value), color='secondary').classes('mt-4')
with ui.element('div'):
ui.label('Data Table').classes('text-lg font-bold p-2')
table_rows_container = ui.grid(columns=2).classes("w-full")
ui.separator()
with ui.element('div'):
ui.label('Figure').classes('text-lg font-bold p-2')
figure_rows_container = ui.row().style("justify-content: center")
chart_ui = ui.html('') # Placeholder for the Plotly char
本文标签: pythonHow to clear the old result using niceGUIStack Overflow
版权声明:本文标题:python - How to clear the old result using niceGUI? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736760377a1951512.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论