Spaces:
Runtime error
Runtime error
Warning message for inputs
Browse files
app.py
CHANGED
|
@@ -122,9 +122,9 @@ def update_save_feedback_button(feedback_rating, feedback_text):
|
|
| 122 |
|
| 123 |
def update_obfuscate_button(input_text):
|
| 124 |
if input_text.strip() == "":
|
| 125 |
-
return gr.update(interactive=False)
|
| 126 |
else:
|
| 127 |
-
return gr.update(interactive=True)
|
| 128 |
|
| 129 |
demo = gr.Blocks()
|
| 130 |
|
|
@@ -136,6 +136,9 @@ with demo:
|
|
| 136 |
label="Input Text",
|
| 137 |
placeholder="The quick brown fox jumped over the lazy dogs."
|
| 138 |
)
|
|
|
|
|
|
|
|
|
|
| 139 |
gr.Markdown("# 2) Style Element Sliders\n### Adjust the style element sliders to the desired levels to steer the obfuscation.")
|
| 140 |
|
| 141 |
reset_button = gr.Button("Choose slider values automatically (based on input text)")
|
|
@@ -184,7 +187,9 @@ with demo:
|
|
| 184 |
obfuscate_button = gr.Button("Obfuscate Text", interactive=False)
|
| 185 |
|
| 186 |
reset_button.click(fn=reset_sliders, inputs=[], outputs=sliders)
|
| 187 |
-
input_text.change(fn=update_obfuscate_button, inputs=input_text, outputs=obfuscate_button)
|
|
|
|
|
|
|
| 188 |
|
| 189 |
with gr.Column(variant="panel"):
|
| 190 |
gr.Markdown("# 3) Obfuscated Output")
|
|
|
|
| 122 |
|
| 123 |
def update_obfuscate_button(input_text):
|
| 124 |
if input_text.strip() == "":
|
| 125 |
+
return gr.update(interactive=False), gr.update(visible=True)
|
| 126 |
else:
|
| 127 |
+
return gr.update(interactive=True), gr.update(visible=False)
|
| 128 |
|
| 129 |
demo = gr.Blocks()
|
| 130 |
|
|
|
|
| 136 |
label="Input Text",
|
| 137 |
placeholder="The quick brown fox jumped over the lazy dogs."
|
| 138 |
)
|
| 139 |
+
warning_message = gr.Markdown(
|
| 140 |
+
"⚠️ Please enter text before obfuscating.", visible=True
|
| 141 |
+
)
|
| 142 |
gr.Markdown("# 2) Style Element Sliders\n### Adjust the style element sliders to the desired levels to steer the obfuscation.")
|
| 143 |
|
| 144 |
reset_button = gr.Button("Choose slider values automatically (based on input text)")
|
|
|
|
| 187 |
obfuscate_button = gr.Button("Obfuscate Text", interactive=False)
|
| 188 |
|
| 189 |
reset_button.click(fn=reset_sliders, inputs=[], outputs=sliders)
|
| 190 |
+
input_text.change(fn=update_obfuscate_button, inputs=input_text, outputs=[obfuscate_button, warning_message])
|
| 191 |
+
# Initialize the button and warning message state on page load
|
| 192 |
+
demo.load(fn=update_obfuscate_button, inputs=input_text, outputs=[obfuscate_button, warning_message])
|
| 193 |
|
| 194 |
with gr.Column(variant="panel"):
|
| 195 |
gr.Markdown("# 3) Obfuscated Output")
|