K00B404 commited on
Commit
894e5d0
·
verified ·
1 Parent(s): cfd3fb6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+
4
+ # Define the tile grid properties
5
+ num_tiles_x = 10
6
+ num_tiles_y = 10
7
+ tile_size = 100
8
+
9
+ # Create the Gradio app
10
+ app = gr.Interface(
11
+ fn=lambda: None, # This is a placeholder, we'll fill it in later
12
+ title="Tile Grid App",
13
+ description="A full-screen tile grid with images and links",
14
+ layouts=[
15
+ [
16
+ gr.Tiles(num_tiles_x, num_tiles_y, tile_size, tile_size, image="unknown", label="Click to visit")
17
+ ]
18
+ ]
19
+ )
20
+
21
+ # Define a function to generate the tile grid
22
+ def generate_tile_grid():
23
+ tile_grid = []
24
+ for i in range(num_tiles_x):
25
+ row = []
26
+ for j in range(num_tiles_y):
27
+ tile_id = f"tile_{i}_{j}"
28
+ image_url = f"https://picsum.photos/200/300" # Replace with your own image URLs
29
+ link_url = f"https://www.example.com/{tile_id}" # Replace with your own link URLs
30
+ row.append(gr.Tile(tile_size, tile_size, image=image_url, label=f"Click to visit {link_url}", clickable=True))
31
+ tile_grid.append(row)
32
+ return tile_grid
33
+
34
+ # Replace the placeholder function with the tile grid generation function
35
+ app.update(fn=generate_tile_grid)
36
+
37
+ # Launch the app
38
+ app.launch()