Update app.py
Browse files
app.py
CHANGED
@@ -68,40 +68,42 @@ if __name__ == "__main__":
|
|
68 |
"""
|
69 |
)
|
70 |
|
71 |
-
# Global Color Picker - Repositioned and
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
74 |
base_color_picker = gr.ColorPicker(
|
75 |
label="Select Base Color for Diagram",
|
76 |
-
value=DEFAULT_BASE_COLOR,
|
77 |
interactive=True,
|
78 |
elem_id="main-color-picker",
|
79 |
-
scale=2 # Allow color picker to take more space
|
80 |
)
|
81 |
-
|
82 |
-
|
|
|
83 |
gr.Markdown("<br>")
|
84 |
|
85 |
with gr.Tabs():
|
86 |
with gr.TabItem("Concept Map"):
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
title="Concept Map Generator",
|
105 |
)
|
106 |
gr.Markdown("<br>")
|
107 |
gr.Markdown("## Example Concept Maps")
|
@@ -110,23 +112,23 @@ if __name__ == "__main__":
|
|
110 |
gr.Image(value="./images/cm2.png", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
111 |
|
112 |
with gr.TabItem("Synoptic Chart"):
|
113 |
-
gr.
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
)
|
131 |
gr.Markdown("<br>")
|
132 |
gr.Markdown("## Example Synoptic Charts")
|
@@ -135,23 +137,23 @@ if __name__ == "__main__":
|
|
135 |
gr.Image(value="./images/sc2.png", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
136 |
|
137 |
with gr.TabItem("Radial Diagram"):
|
138 |
-
gr.
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
)
|
156 |
gr.Markdown("<br>")
|
157 |
gr.Markdown("## Example Radial Diagrams")
|
@@ -161,23 +163,23 @@ if __name__ == "__main__":
|
|
161 |
|
162 |
# New Tab for Process Flow Diagram
|
163 |
with gr.TabItem("Process Flow"):
|
164 |
-
gr.
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
)
|
182 |
gr.Markdown("<br>")
|
183 |
gr.Markdown("## Example Process Flow Diagrams")
|
@@ -187,23 +189,23 @@ if __name__ == "__main__":
|
|
187 |
|
188 |
# New Tab for WBS Diagram
|
189 |
with gr.TabItem("WBS Diagram"):
|
190 |
-
gr.
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
)
|
208 |
gr.Markdown("<br>")
|
209 |
gr.Markdown("## Example WBS Diagrams")
|
|
|
68 |
"""
|
69 |
)
|
70 |
|
71 |
+
# Global Color Picker - Repositioned for clarity and function
|
72 |
+
# This will hold the *value* of the currently selected color
|
73 |
+
current_base_color = gr.State(DEFAULT_BASE_COLOR)
|
74 |
+
|
75 |
+
with gr.Row(variant="panel"): # Simplified Row, removed equal_height
|
76 |
+
gr.Markdown("### Main Diagram Color")
|
77 |
base_color_picker = gr.ColorPicker(
|
78 |
label="Select Base Color for Diagram",
|
79 |
+
value=DEFAULT_BASE_COLOR,
|
80 |
interactive=True,
|
81 |
elem_id="main-color-picker",
|
|
|
82 |
)
|
83 |
+
# Update the gr.State variable whenever the color picker changes
|
84 |
+
base_color_picker.change(fn=lambda x: x, inputs=base_color_picker, outputs=current_base_color)
|
85 |
+
|
86 |
gr.Markdown("<br>")
|
87 |
|
88 |
with gr.Tabs():
|
89 |
with gr.TabItem("Concept Map"):
|
90 |
+
json_input_cm = gr.Textbox(
|
91 |
+
value=CONCEPT_MAP_JSON,
|
92 |
+
placeholder="Paste JSON following the documented format",
|
93 |
+
label="Structured JSON Input",
|
94 |
+
lines=25
|
95 |
+
)
|
96 |
+
output_cm = gr.Image(
|
97 |
+
label="Generated Graph",
|
98 |
+
type="filepath",
|
99 |
+
show_download_button=True
|
100 |
+
)
|
101 |
+
submit_btn_cm = gr.Button("Submit")
|
102 |
+
|
103 |
+
submit_btn_cm.click(
|
104 |
+
fn=generate_concept_map,
|
105 |
+
inputs=[json_input_cm, current_base_color], # Pass the State's value
|
106 |
+
outputs=output_cm
|
|
|
107 |
)
|
108 |
gr.Markdown("<br>")
|
109 |
gr.Markdown("## Example Concept Maps")
|
|
|
112 |
gr.Image(value="./images/cm2.png", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
113 |
|
114 |
with gr.TabItem("Synoptic Chart"):
|
115 |
+
json_input_sc = gr.Textbox(
|
116 |
+
value=SYNOPTIC_CHART_JSON,
|
117 |
+
placeholder="Paste JSON following the documented format",
|
118 |
+
label="Structured JSON Input",
|
119 |
+
lines=25
|
120 |
+
)
|
121 |
+
output_sc = gr.Image(
|
122 |
+
label="Generated Graph",
|
123 |
+
type="filepath",
|
124 |
+
show_download_button=True
|
125 |
+
)
|
126 |
+
submit_btn_sc = gr.Button("Submit")
|
127 |
+
|
128 |
+
submit_btn_sc.click(
|
129 |
+
fn=generate_synoptic_chart,
|
130 |
+
inputs=[json_input_sc, current_base_color], # Pass the State's value
|
131 |
+
outputs=output_sc
|
132 |
)
|
133 |
gr.Markdown("<br>")
|
134 |
gr.Markdown("## Example Synoptic Charts")
|
|
|
137 |
gr.Image(value="./images/sc2.png", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
138 |
|
139 |
with gr.TabItem("Radial Diagram"):
|
140 |
+
json_input_rd = gr.Textbox(
|
141 |
+
value=RADIAL_DIAGRAM_JSON,
|
142 |
+
placeholder="Paste JSON following the documented format",
|
143 |
+
label="Structured JSON Input",
|
144 |
+
lines=25
|
145 |
+
)
|
146 |
+
output_rd = gr.Image(
|
147 |
+
label="Generated Graph",
|
148 |
+
type="filepath",
|
149 |
+
show_download_button=True
|
150 |
+
)
|
151 |
+
submit_btn_rd = gr.Button("Submit")
|
152 |
+
|
153 |
+
submit_btn_rd.click(
|
154 |
+
fn=generate_radial_diagram,
|
155 |
+
inputs=[json_input_rd, current_base_color], # Pass the State's value
|
156 |
+
outputs=output_rd
|
157 |
)
|
158 |
gr.Markdown("<br>")
|
159 |
gr.Markdown("## Example Radial Diagrams")
|
|
|
163 |
|
164 |
# New Tab for Process Flow Diagram
|
165 |
with gr.TabItem("Process Flow"):
|
166 |
+
json_input_pf = gr.Textbox(
|
167 |
+
value=PROCESS_FLOW_JSON,
|
168 |
+
placeholder="Paste JSON following the documented format",
|
169 |
+
label="Structured JSON Input",
|
170 |
+
lines=25
|
171 |
+
)
|
172 |
+
output_pf = gr.Image(
|
173 |
+
label="Generated Graph",
|
174 |
+
type="filepath",
|
175 |
+
show_download_button=True
|
176 |
+
)
|
177 |
+
submit_btn_pf = gr.Button("Submit")
|
178 |
+
|
179 |
+
submit_btn_pf.click(
|
180 |
+
fn=generate_process_flow_diagram,
|
181 |
+
inputs=[json_input_pf, current_base_color], # Pass the State's value
|
182 |
+
outputs=output_pf
|
183 |
)
|
184 |
gr.Markdown("<br>")
|
185 |
gr.Markdown("## Example Process Flow Diagrams")
|
|
|
189 |
|
190 |
# New Tab for WBS Diagram
|
191 |
with gr.TabItem("WBS Diagram"):
|
192 |
+
json_input_wbs = gr.Textbox(
|
193 |
+
value=WBS_DIAGRAM_JSON,
|
194 |
+
placeholder="Paste JSON following the documented format",
|
195 |
+
label="Structured JSON Input",
|
196 |
+
lines=25
|
197 |
+
)
|
198 |
+
output_wbs = gr.Image(
|
199 |
+
label="Generated Graph",
|
200 |
+
type="filepath",
|
201 |
+
show_download_button=True
|
202 |
+
)
|
203 |
+
submit_btn_wbs = gr.Button("Submit")
|
204 |
+
|
205 |
+
submit_btn_wbs.click(
|
206 |
+
fn=generate_wbs_diagram,
|
207 |
+
inputs=[json_input_wbs, current_base_color], # Pass the State's value
|
208 |
+
outputs=output_wbs
|
209 |
)
|
210 |
gr.Markdown("<br>")
|
211 |
gr.Markdown("## Example WBS Diagrams")
|