Spaces:
Running
on
Zero
Running
on
Zero
viklofg
commited on
Commit
·
f9141c6
1
Parent(s):
8e99520
Update tab handling
Browse files- Make Result and Export tabs non-interactive when no result
is available
- Automatically switch to the result tab when the result is ready
- app/main.py +10 -2
app/main.py
CHANGED
@@ -27,6 +27,10 @@ def load_markdown(language, section, content_dir="app/content"):
|
|
27 |
return f"## Content missing for {file_path} in {language}"
|
28 |
|
29 |
|
|
|
|
|
|
|
|
|
30 |
matomo = """
|
31 |
<!-- Matomo -->
|
32 |
<script>
|
@@ -61,10 +65,10 @@ with gr.Blocks(title="HTRflow", theme=theme, css=css, head=matomo) as demo:
|
|
61 |
with gr.Tabs(elem_classes="top-navbar") as navbar:
|
62 |
with gr.Tab(label="Upload") as tab_submit:
|
63 |
submit.render()
|
64 |
-
with gr.Tab(label="Result") as tab_visualizer:
|
65 |
visualizer.render()
|
66 |
|
67 |
-
with gr.Tab(label="Export") as tab_export:
|
68 |
export.render()
|
69 |
|
70 |
@demo.load()
|
@@ -76,6 +80,10 @@ with gr.Blocks(title="HTRflow", theme=theme, css=css, head=matomo) as demo:
|
|
76 |
state_value = input_value
|
77 |
return state_value if state_value is not None else gr.skip()
|
78 |
|
|
|
|
|
|
|
|
|
79 |
tab_visualizer.select(
|
80 |
inputs=[collection_submit_state, collection_viz_state],
|
81 |
outputs=[collection_viz_state],
|
|
|
27 |
return f"## Content missing for {file_path} in {language}"
|
28 |
|
29 |
|
30 |
+
def activate_tab(collection):
|
31 |
+
return gr.update(interactive = collection is not None)
|
32 |
+
|
33 |
+
|
34 |
matomo = """
|
35 |
<!-- Matomo -->
|
36 |
<script>
|
|
|
65 |
with gr.Tabs(elem_classes="top-navbar") as navbar:
|
66 |
with gr.Tab(label="Upload") as tab_submit:
|
67 |
submit.render()
|
68 |
+
with gr.Tab(label="Result", interactive=False, id="result") as tab_visualizer:
|
69 |
visualizer.render()
|
70 |
|
71 |
+
with gr.Tab(label="Export", interactive=False) as tab_export:
|
72 |
export.render()
|
73 |
|
74 |
@demo.load()
|
|
|
80 |
state_value = input_value
|
81 |
return state_value if state_value is not None else gr.skip()
|
82 |
|
83 |
+
collection_submit_state.change(activate_tab, collection_submit_state, tab_visualizer)
|
84 |
+
collection_submit_state.change(activate_tab, collection_submit_state, tab_export)
|
85 |
+
collection_submit_state.change(lambda: gr.Tabs(selected="result"), outputs=navbar)
|
86 |
+
|
87 |
tab_visualizer.select(
|
88 |
inputs=[collection_submit_state, collection_viz_state],
|
89 |
outputs=[collection_viz_state],
|