import time

import gradio as gr

on_load="""
async()=>{
    console.log("HELLO");
}
"""

def test(x, request: gr.Request, progress=gr.Progress()):
    progress(0, desc="Test", unit = "Files")
    print("request", request)    
    a = "abcdefghijklmnopqrstuv"    
    for letter in progress.tqdm(a, desc = "TEST", unit = "Files"):
        time.sleep(0.1)
    return a  

with gr.Blocks() as demo:

    selected = gr.Dataframe(
        interactive=False,
        col_count=(1, "fixed"),
        headers=["Selected Files"],
    )
    prog = gr.HTML(
        value="<h3 style='text-align: center'> Processing...<h1>"
    )
    #gr.Interface(test, inputs=[selected])
    b = gr.Button()
    
    b.click(test, selected, prog)
    
    demo.load(test, inputs=None, outputs=prog) #, _js=on_load)    
    
demo.launch()