Spaces:
Runtime error
Runtime error
kwabs22
commited on
Commit
·
e1c091b
1
Parent(s):
9cb6ce3
editing placeholder debug
Browse files
app.py
CHANGED
|
@@ -207,6 +207,51 @@ def show_elements_json_input(json_input):
|
|
| 207 |
|
| 208 |
# return outputs
|
| 209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
data = json.loads(json_input)
|
| 211 |
masterlocation1 = data['masterlocation1']
|
| 212 |
|
|
@@ -220,13 +265,13 @@ def show_elements_json_input(json_input):
|
|
| 220 |
description = gr.Textbox(label="Description", value=details['description'])
|
| 221 |
outputs.append(description)
|
| 222 |
|
| 223 |
-
events = gr.
|
| 224 |
outputs.append(events)
|
| 225 |
|
| 226 |
-
choices = gr.
|
| 227 |
outputs.append(choices)
|
| 228 |
|
| 229 |
-
transitions = gr.
|
| 230 |
outputs.append(transitions)
|
| 231 |
|
| 232 |
def update_json():
|
|
@@ -236,15 +281,15 @@ def show_elements_json_input(json_input):
|
|
| 236 |
continue
|
| 237 |
updated_data["masterlocation1"][location] = {
|
| 238 |
"description": outputs[i*4].value,
|
| 239 |
-
"events": outputs[i*4 + 1].value,
|
| 240 |
-
"choices": outputs[i*4 + 2].value,
|
| 241 |
-
"transitions": outputs[i*4 + 3].value
|
| 242 |
}
|
| 243 |
updated_data["masterlocation1"]["end"] = masterlocation1["end"]
|
| 244 |
return json.dumps(updated_data, indent=2)
|
| 245 |
|
| 246 |
update_button = gr.Button("Update JSON")
|
| 247 |
-
json_output = gr.
|
| 248 |
|
| 249 |
update_button.click(update_json, outputs=json_output)
|
| 250 |
|
|
|
|
| 207 |
|
| 208 |
# return outputs
|
| 209 |
|
| 210 |
+
#================================================================================================
|
| 211 |
+
# data = json.loads(json_input)
|
| 212 |
+
# masterlocation1 = data['masterlocation1']
|
| 213 |
+
|
| 214 |
+
# outputs = []
|
| 215 |
+
|
| 216 |
+
# for location, details in masterlocation1.items():
|
| 217 |
+
# if location == 'end':
|
| 218 |
+
# continue
|
| 219 |
+
|
| 220 |
+
# with gr.Accordion(f"Location: {location}"):
|
| 221 |
+
# description = gr.Textbox(label="Description", value=details['description'])
|
| 222 |
+
# outputs.append(description)
|
| 223 |
+
|
| 224 |
+
# events = gr.JSON(label="Events", value=details['events'])
|
| 225 |
+
# outputs.append(events)
|
| 226 |
+
|
| 227 |
+
# choices = gr.JSON(label="Choices", value=details['choices'])
|
| 228 |
+
# outputs.append(choices)
|
| 229 |
+
|
| 230 |
+
# transitions = gr.JSON(label="Transitions", value=details['transitions'])
|
| 231 |
+
# outputs.append(transitions)
|
| 232 |
+
|
| 233 |
+
# def update_json():
|
| 234 |
+
# updated_data = {"masterlocation1": {}}
|
| 235 |
+
# for i, location in enumerate(masterlocation1.keys()):
|
| 236 |
+
# if location == 'end':
|
| 237 |
+
# continue
|
| 238 |
+
# updated_data["masterlocation1"][location] = {
|
| 239 |
+
# "description": outputs[i*4].value,
|
| 240 |
+
# "events": outputs[i*4 + 1].value,
|
| 241 |
+
# "choices": outputs[i*4 + 2].value,
|
| 242 |
+
# "transitions": outputs[i*4 + 3].value
|
| 243 |
+
# }
|
| 244 |
+
# updated_data["masterlocation1"]["end"] = masterlocation1["end"]
|
| 245 |
+
# return json.dumps(updated_data, indent=2)
|
| 246 |
+
|
| 247 |
+
# update_button = gr.Button("Update JSON")
|
| 248 |
+
# json_output = gr.JSON(label="Updated JSON")
|
| 249 |
+
|
| 250 |
+
# update_button.click(update_json, outputs=json_output)
|
| 251 |
+
|
| 252 |
+
# return outputs + [update_button, json_output]
|
| 253 |
+
|
| 254 |
+
#================================================================================================
|
| 255 |
data = json.loads(json_input)
|
| 256 |
masterlocation1 = data['masterlocation1']
|
| 257 |
|
|
|
|
| 265 |
description = gr.Textbox(label="Description", value=details['description'])
|
| 266 |
outputs.append(description)
|
| 267 |
|
| 268 |
+
events = gr.Textbox(label="Events", value=json.dumps(details['events']))
|
| 269 |
outputs.append(events)
|
| 270 |
|
| 271 |
+
choices = gr.Textbox(label="Choices", value=json.dumps(details['choices']))
|
| 272 |
outputs.append(choices)
|
| 273 |
|
| 274 |
+
transitions = gr.Textbox(label="Transitions", value=json.dumps(details['transitions']))
|
| 275 |
outputs.append(transitions)
|
| 276 |
|
| 277 |
def update_json():
|
|
|
|
| 281 |
continue
|
| 282 |
updated_data["masterlocation1"][location] = {
|
| 283 |
"description": outputs[i*4].value,
|
| 284 |
+
"events": json.loads(outputs[i*4 + 1].value),
|
| 285 |
+
"choices": json.loads(outputs[i*4 + 2].value),
|
| 286 |
+
"transitions": json.loads(outputs[i*4 + 3].value)
|
| 287 |
}
|
| 288 |
updated_data["masterlocation1"]["end"] = masterlocation1["end"]
|
| 289 |
return json.dumps(updated_data, indent=2)
|
| 290 |
|
| 291 |
update_button = gr.Button("Update JSON")
|
| 292 |
+
json_output = gr.Textbox(label="Updated JSON", lines=10)
|
| 293 |
|
| 294 |
update_button.click(update_json, outputs=json_output)
|
| 295 |
|