Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| # Create a Gradio Blocks app | |
| demo = gr.Blocks() | |
| # Define the layout and components within the Blocks app | |
| with demo: | |
| # Input Textbox for user to enter text | |
| inp = gr.Textbox(placeholder="Enter text.") | |
| # Button to trigger scrolling to the output | |
| scroll_btn = gr.Button("Scroll") | |
| # Button to trigger output without scrolling | |
| no_scroll_btn = gr.Button("No Scroll") | |
| # A large HTML block to simulate a long page | |
| big_block = gr.HTML(""" | |
| <div style='height: 860px; width: 100px; background-color: pink;'></div> | |
| """) | |
| # Output Textbox to display the result | |
| out = gr.Textbox() | |
| # Event listener for the "Scroll" button | |
| scroll_btn.click(lambda x: x, | |
| inputs=inp, | |
| outputs=out, | |
| scroll_to_output=True) # Scroll to the output after updating | |
| # Event listener for the "No Scroll" button | |
| no_scroll_btn.click(lambda x: x, | |
| inputs=inp, | |
| outputs=out) # Do not scroll to the output after updating | |
| # Launch the Gradio app | |
| if __name__ == "__main__": | |
| demo.launch(show_error=True) |