Spaces:
Runtime error
Runtime error
Commit
·
2100a52
1
Parent(s):
e122da3
Update app.py
Browse files
app.py
CHANGED
|
@@ -201,28 +201,31 @@ with gr.Blocks(theme=theme, title="New Look", css=css) as demo:
|
|
| 201 |
product_link = gr.State()
|
| 202 |
button_go_to_page = gr.Button(value="Go to product page")
|
| 203 |
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
# with gr.Tab(label="Search for images"):
|
| 228 |
# labels_input = gr.Text(label="List of labels")
|
|
|
|
| 201 |
product_link = gr.State()
|
| 202 |
button_go_to_page = gr.Button(value="Go to product page")
|
| 203 |
|
| 204 |
+
page = gr.HTML()
|
| 205 |
+
|
| 206 |
+
def on_new_text_box(more_text_search): # SelectData is a subclass of EventData
|
| 207 |
+
if more_text_search == "Search with more text":
|
| 208 |
+
return gr.update(visible=True, interactive=True), gr.update(visible=True, interactive=True), gr.update(value="Hide extra text box")
|
| 209 |
+
else:
|
| 210 |
+
return gr.update(value="", visible=False, interactive=False), gr.update(visible=False, interactive=False), gr.update(value="Search with more text")
|
| 211 |
+
|
| 212 |
+
def on_focus(evt: gr.SelectData): # SelectData is a subclass of EventData
|
| 213 |
+
return return_item(evt.value)
|
| 214 |
+
|
| 215 |
+
def on_new_image_to_search(images, evt: gr.SelectData): # SelectData is a subclass of EventData
|
| 216 |
+
return return_primary_item(evt.value)
|
| 217 |
+
|
| 218 |
+
def on_go_to_product_page(product_link):
|
| 219 |
+
# try:
|
| 220 |
+
return gr.update(value="<a href= " + product_link +" target='_blank'> waht </a>")
|
| 221 |
+
# webbrowser.open(product_link)
|
| 222 |
+
# except:
|
| 223 |
+
# print("Not able to open product page")
|
| 224 |
+
|
| 225 |
+
more_text_search.click(on_new_text_box, more_text_search, [text_input_1, text_relevance_1, more_text_search])
|
| 226 |
+
images_gallery.select(on_focus, None, [detail_gallery, image_description, product_link])
|
| 227 |
+
detail_gallery.select(on_new_image_to_search, detail_gallery, image_input)
|
| 228 |
+
button_go_to_page.click(on_go_to_product_page, product_link, page)
|
| 229 |
|
| 230 |
# with gr.Tab(label="Search for images"):
|
| 231 |
# labels_input = gr.Text(label="List of labels")
|