Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
import pandas as pd
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
with gr.Blocks() as blocks:
|
6 |
+
|
7 |
+
def update_first_df(df):
|
8 |
+
print('update first df')
|
9 |
+
time.sleep(1)
|
10 |
+
return df + 1
|
11 |
+
|
12 |
+
def update_second_df(df):
|
13 |
+
print('update second df')
|
14 |
+
time.sleep(1)
|
15 |
+
return df + 1
|
16 |
+
|
17 |
+
first_df = gr.Dataframe(pd.DataFrame({'A': [1], 'B': [2]}))
|
18 |
+
second_df = gr.Dataframe(pd.DataFrame({'A': [3], 'B': [4]}))
|
19 |
+
|
20 |
+
first_df.select(fn=update_second_df, inputs=[second_df], outputs=[second_df])
|
21 |
+
second_df.select(fn=update_first_df, inputs=[first_df], outputs=[first_df])
|
22 |
+
|
23 |
+
|
24 |
+
blocks.launch()
|