Spaces:
Sleeping
Sleeping
File size: 2,375 Bytes
f4748ec cf2f7be a995c5b 1b1b958 a995c5b 1b1b958 a995c5b 1b1b958 a995c5b f4748ec cf2f7be f4748ec a995c5b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
from gradio import Blocks, Button, Row, Markdown, Textbox, Column, Files
from gradio import Button, Textbox, Files
class EventsHandler:
def __init__(self) -> None:
...
def click_run_button(self, input_text: str):
files = Files(
value= [
'/app/config/logging/app.log'
],
visible= True
)
input_text = Textbox(
value= input_text,
interactive= False
)
appr_btn, disappr_btn = Button(value= "✅", visible= True), Button(value= "❌", visible= True)
return [input_text, files, appr_btn, disappr_btn]
async def click_clear_button(self):
input_text = Textbox(placeholder="Escriba la búsqueda aquí",label= "Búsqueda", value= "", interactive= True)
out_files = Files(interactive= False, file_count= "multiple", visible= False)
appr_btn, disappr_btn = Button(value= "✅", visible= False), Button(value= "❌", visible= False)
return [input_text, out_files, appr_btn, disappr_btn]
async def click_appr_button(self, input_text: str, out_files: list):
...
async def click_disappr_button(self, input_text: str, out_files: list):
...
with Blocks() as app:
Markdown("Start typing below and then click **Run** to see the output.")
with Row():
with Column():
input_text = Textbox(placeholder="Escriba la búsqueda aquí", label= "Búsqueda")
with Row():
run_btn, clear_btn = Button("Buscar", variant= "primary"), Button("Clear", variant= "secondary")
with Column():
out_files = Files(interactive= False, file_count= "multiple", visible= False)
with Row():
appr_btn, disappr_btn = Button(value= "✅", visible= False), Button(value= "❌", visible= False)
events_handler = EventsHandler()
run_btn.click(events_handler.click_run_button, inputs=input_text, outputs= [input_text, out_files, appr_btn, disappr_btn])
clear_btn.click(events_handler.click_clear_button, inputs= [], outputs= [input_text, out_files, appr_btn, disappr_btn])
appr_btn.click(events_handler.click_appr_button, inputs= [input_text, out_files], outputs= None)
disappr_btn.click(events_handler.click_disappr_button, inputs= [input_text, out_files], outputs= None)
app.launch()
|