| | import gradio as gr |
| | import numpy as np |
| |
|
| | |
| | num_tiles_x = 10 |
| | num_tiles_y = 10 |
| | tile_size = 100 |
| |
|
| | |
| | tile_data = [ |
| | {"image": "https://picsum.photos/200/300", "link": "https://www.example.com", "click": "https://www.example.com"}, |
| | {"image": "https://picsum.photos/200/301", "link": "https://www.example.com", "click": "https://www.example.com"}, |
| | {"image": "https://picsum.photos/200/302", "link": "https://www.example.com", "click": "https://www.example.com"}, |
| | |
| | ] |
| |
|
| | |
| | app = gr.Interface( |
| | fn=lambda: None, |
| | title="Tile Grid App", |
| | description="A full-screen tile grid with images and links", |
| | layouts=[ |
| | [ |
| | gr.Column( |
| | [gr.Row([gr.Image(img=image["image"], width=tile_size, height=tile_size), gr.Button(label="Click to visit", click=image["click"])]) for image in tile_data[i * num_tiles_y:(i + 1) * num_tiles_y]]) for i in range(num_tiles_x) |
| | ) |
| | ] |
| | ] |
| | ) |
| |
|
| | |
| | def generate_tile_grid(): |
| | return [gr.Row([gr.Image(img=image["image"], width=tile_size, height=tile_size), gr.Button(label="Click to visit", click=image["click"])]) for image in tile_data] |
| |
|
| | |
| | app.update(fn=generate_tile_grid) |
| |
|
| | |
| | app.launch() |