Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -135,11 +135,11 @@ def prompt_generator_app(data_manager):
|
|
| 135 |
with gr.Group():
|
| 136 |
gr.Markdown("### Character Selection")
|
| 137 |
|
| 138 |
-
#
|
| 139 |
-
|
| 140 |
-
selected_character_names = gr.State([])
|
| 141 |
|
| 142 |
characters_display = gr.HTML()
|
|
|
|
| 143 |
refresh_characters_button = gr.Button("Refresh Character List")
|
| 144 |
|
| 145 |
# Number of people in the scene
|
|
@@ -155,7 +155,7 @@ def prompt_generator_app(data_manager):
|
|
| 155 |
def display_characters():
|
| 156 |
characters = data_manager.get_characters()
|
| 157 |
if not characters:
|
| 158 |
-
return ""
|
| 159 |
|
| 160 |
# Build HTML content for characters display
|
| 161 |
html_content = "<div style='display: flex; flex-wrap: wrap;'>"
|
|
@@ -190,19 +190,18 @@ def prompt_generator_app(data_manager):
|
|
| 190 |
selected.push(checkboxes[i].value);
|
| 191 |
}
|
| 192 |
}
|
| 193 |
-
|
| 194 |
}
|
| 195 |
</script>
|
| 196 |
"""
|
| 197 |
|
| 198 |
-
return html_content
|
| 199 |
|
| 200 |
-
#
|
| 201 |
-
characters_display.
|
| 202 |
-
refresh_characters_button.click(display_characters, outputs=characters_display)
|
| 203 |
|
| 204 |
-
#
|
| 205 |
-
|
| 206 |
|
| 207 |
def generate_prompt(*args):
|
| 208 |
# args correspond to inputs in the order they are defined
|
|
|
|
| 135 |
with gr.Group():
|
| 136 |
gr.Markdown("### Character Selection")
|
| 137 |
|
| 138 |
+
# Placeholders for dynamic components
|
| 139 |
+
hidden_selected_characters = gr.Textbox(visible=False, elem_id='selected_character_names')
|
|
|
|
| 140 |
|
| 141 |
characters_display = gr.HTML()
|
| 142 |
+
|
| 143 |
refresh_characters_button = gr.Button("Refresh Character List")
|
| 144 |
|
| 145 |
# Number of people in the scene
|
|
|
|
| 155 |
def display_characters():
|
| 156 |
characters = data_manager.get_characters()
|
| 157 |
if not characters:
|
| 158 |
+
return "<p>No characters available. Please add characters in the Character Creation tab.</p>"
|
| 159 |
|
| 160 |
# Build HTML content for characters display
|
| 161 |
html_content = "<div style='display: flex; flex-wrap: wrap;'>"
|
|
|
|
| 190 |
selected.push(checkboxes[i].value);
|
| 191 |
}
|
| 192 |
}
|
| 193 |
+
document.getElementById('selected_character_names').value = JSON.stringify(selected);
|
| 194 |
}
|
| 195 |
</script>
|
| 196 |
"""
|
| 197 |
|
| 198 |
+
return html_content
|
| 199 |
|
| 200 |
+
# Initialize characters_display with the HTML content
|
| 201 |
+
characters_display.value = display_characters()
|
|
|
|
| 202 |
|
| 203 |
+
# When refresh_characters_button is clicked, update characters_display
|
| 204 |
+
refresh_characters_button.click(fn=display_characters, outputs=characters_display)
|
| 205 |
|
| 206 |
def generate_prompt(*args):
|
| 207 |
# args correspond to inputs in the order they are defined
|