v0.0.9 fix demo and readme
Browse files
README.md
CHANGED
|
@@ -6,7 +6,7 @@ tags:
|
|
| 6 |
- textbox
|
| 7 |
- editing
|
| 8 |
- color
|
| 9 |
-
title: gradio_highlightedtextbox v0.0.
|
| 10 |
colorFrom: indigo
|
| 11 |
colorTo: green
|
| 12 |
sdk: docker
|
|
|
|
| 6 |
- textbox
|
| 7 |
- editing
|
| 8 |
- color
|
| 9 |
+
title: gradio_highlightedtextbox v0.0.9
|
| 10 |
colorFrom: indigo
|
| 11 |
colorTo: green
|
| 12 |
sdk: docker
|
app.py
CHANGED
|
@@ -111,6 +111,11 @@ _docs = {
|
|
| 111 |
"default": "False",
|
| 112 |
"description": "If True, includes a copy button to copy the text in the textbox. Only applies if show_label is True.",
|
| 113 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
},
|
| 115 |
"postprocess": {
|
| 116 |
"y": {
|
|
@@ -158,6 +163,11 @@ _docs = {
|
|
| 158 |
"default": None,
|
| 159 |
"description": "This listener is triggered when the HighlightedTextbox is unfocused/blurred.",
|
| 160 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
},
|
| 162 |
},
|
| 163 |
"__meta__": {
|
|
@@ -203,7 +213,7 @@ def show_info(
|
|
| 203 |
)
|
| 204 |
|
| 205 |
|
| 206 |
-
initial_text = "It is not something to be ashamed of: it is no different from the <
|
| 207 |
|
| 208 |
with gr.Blocks(
|
| 209 |
css=abs_path,
|
|
@@ -218,8 +228,8 @@ with gr.Blocks(
|
|
| 218 |
gr.Markdown("### Parameters to control the highlighted textbox:")
|
| 219 |
with gr.Row():
|
| 220 |
tag_id = gr.Dropdown(
|
| 221 |
-
choices=["
|
| 222 |
-
value=["
|
| 223 |
multiselect=True,
|
| 224 |
allow_custom_value=True,
|
| 225 |
label="Tag ID",
|
|
@@ -227,8 +237,8 @@ with gr.Blocks(
|
|
| 227 |
info="Insert one or more tag IDs to use in the highlighted textbox.",
|
| 228 |
)
|
| 229 |
tag_open = gr.Dropdown(
|
| 230 |
-
choices=["<
|
| 231 |
-
value=["<
|
| 232 |
multiselect=True,
|
| 233 |
allow_custom_value=True,
|
| 234 |
label="Tag open",
|
|
@@ -236,8 +246,8 @@ with gr.Blocks(
|
|
| 236 |
info="Insert one or more tags to mark the beginning of a highlighted section.",
|
| 237 |
)
|
| 238 |
tag_close = gr.Dropdown(
|
| 239 |
-
choices=["</
|
| 240 |
-
value=["</
|
| 241 |
multiselect=True,
|
| 242 |
allow_custom_value=True,
|
| 243 |
label="Tag close",
|
|
@@ -246,14 +256,14 @@ with gr.Blocks(
|
|
| 246 |
)
|
| 247 |
gr.Markdown(
|
| 248 |
"""
|
| 249 |
-
### Example:
|
| 250 |
|
| 251 |
-
The following text is tagged using the parameters above to mark spans that will be highlighted.
|
| 252 |
|
| 253 |
-
Both the tagged text and the highlighted text are editable, so you can see how the changes in one affect the other.
|
| 254 |
|
| 255 |
-
Highlights will disappear if the highlighted text is edited. Modals will appear upon focus, change, and blur events on the highlighted text.
|
| 256 |
-
"""
|
| 257 |
)
|
| 258 |
with gr.Row():
|
| 259 |
tagged = gr.Textbox(
|
|
@@ -274,6 +284,8 @@ Highlights will disappear if the highlighted text is edited. Modals will appear
|
|
| 274 |
show_label=True,
|
| 275 |
legend_label="Legend:",
|
| 276 |
show_legend_label=True,
|
|
|
|
|
|
|
| 277 |
)
|
| 278 |
|
| 279 |
# Functions
|
|
@@ -293,14 +305,14 @@ Highlights will disappear if the highlighted text is edited. Modals will appear
|
|
| 293 |
inputs=[high, tag_id, tag_open, tag_close, gr.State("Focus")],
|
| 294 |
outputs=None,
|
| 295 |
)
|
| 296 |
-
high.
|
| 297 |
fn=show_info,
|
| 298 |
-
inputs=[high, tag_id, tag_open, tag_close, gr.State("
|
| 299 |
outputs=None,
|
| 300 |
)
|
| 301 |
-
high.
|
| 302 |
fn=show_info,
|
| 303 |
-
inputs=[high, tag_id, tag_open, tag_close, gr.State("
|
| 304 |
outputs=None,
|
| 305 |
)
|
| 306 |
with gr.Tab("Docs"):
|
|
|
|
| 111 |
"default": "False",
|
| 112 |
"description": "If True, includes a copy button to copy the text in the textbox. Only applies if show_label is True.",
|
| 113 |
},
|
| 114 |
+
"show_remove_tags_button": {
|
| 115 |
+
"type": "bool",
|
| 116 |
+
"default": "False",
|
| 117 |
+
"description": "If True, includes a remove tags button to remove all highlights from the text.",
|
| 118 |
+
},
|
| 119 |
},
|
| 120 |
"postprocess": {
|
| 121 |
"y": {
|
|
|
|
| 163 |
"default": None,
|
| 164 |
"description": "This listener is triggered when the HighlightedTextbox is unfocused/blurred.",
|
| 165 |
},
|
| 166 |
+
"clear": {
|
| 167 |
+
"type": None,
|
| 168 |
+
"default": None,
|
| 169 |
+
"description": "This listener is triggered when the HighlightedTextbox is cleared from highlights using the remove_tags button.",
|
| 170 |
+
},
|
| 171 |
},
|
| 172 |
},
|
| 173 |
"__meta__": {
|
|
|
|
| 213 |
)
|
| 214 |
|
| 215 |
|
| 216 |
+
initial_text = "It is not something to be ashamed of: it is no different from the <a>personal fears</a> and <b>dislikes</b> of other things that <c>manny peopl</c> have."
|
| 217 |
|
| 218 |
with gr.Blocks(
|
| 219 |
css=abs_path,
|
|
|
|
| 228 |
gr.Markdown("### Parameters to control the highlighted textbox:")
|
| 229 |
with gr.Row():
|
| 230 |
tag_id = gr.Dropdown(
|
| 231 |
+
choices=["Error A", "Error B", "Error C"],
|
| 232 |
+
value=["Error A", "Error B", "Error C"],
|
| 233 |
multiselect=True,
|
| 234 |
allow_custom_value=True,
|
| 235 |
label="Tag ID",
|
|
|
|
| 237 |
info="Insert one or more tag IDs to use in the highlighted textbox.",
|
| 238 |
)
|
| 239 |
tag_open = gr.Dropdown(
|
| 240 |
+
choices=["<a>", "<b>", "<c>"],
|
| 241 |
+
value=["<a>", "<b>", "<c>"],
|
| 242 |
multiselect=True,
|
| 243 |
allow_custom_value=True,
|
| 244 |
label="Tag open",
|
|
|
|
| 246 |
info="Insert one or more tags to mark the beginning of a highlighted section.",
|
| 247 |
)
|
| 248 |
tag_close = gr.Dropdown(
|
| 249 |
+
choices=["</a>", "</b>", "</c>"],
|
| 250 |
+
value=["</a>", "</b>", "</c>"],
|
| 251 |
multiselect=True,
|
| 252 |
allow_custom_value=True,
|
| 253 |
label="Tag close",
|
|
|
|
| 256 |
)
|
| 257 |
gr.Markdown(
|
| 258 |
"""
|
| 259 |
+
### Example:
|
| 260 |
|
| 261 |
+
The following text is tagged using the parameters above to mark spans that will be highlighted.
|
| 262 |
|
| 263 |
+
Both the tagged text and the highlighted text are editable, so you can see how the changes in one affect the other.
|
| 264 |
|
| 265 |
+
Highlights will disappear if the highlighted text is edited. Modals will appear upon focus, change, and blur events on the highlighted text.
|
| 266 |
+
"""
|
| 267 |
)
|
| 268 |
with gr.Row():
|
| 269 |
tagged = gr.Textbox(
|
|
|
|
| 284 |
show_label=True,
|
| 285 |
legend_label="Legend:",
|
| 286 |
show_legend_label=True,
|
| 287 |
+
show_remove_tags_button=True,
|
| 288 |
+
show_copy_button=False,
|
| 289 |
)
|
| 290 |
|
| 291 |
# Functions
|
|
|
|
| 305 |
inputs=[high, tag_id, tag_open, tag_close, gr.State("Focus")],
|
| 306 |
outputs=None,
|
| 307 |
)
|
| 308 |
+
high.blur(
|
| 309 |
fn=show_info,
|
| 310 |
+
inputs=[high, tag_id, tag_open, tag_close, gr.State("Blur")],
|
| 311 |
outputs=None,
|
| 312 |
)
|
| 313 |
+
high.clear(
|
| 314 |
fn=show_info,
|
| 315 |
+
inputs=[high, tag_id, tag_open, tag_close, gr.State("Remove tags")],
|
| 316 |
outputs=None,
|
| 317 |
)
|
| 318 |
with gr.Tab("Docs"):
|