File size: 961 Bytes
5a89aea
 
 
 
b9dab17
 
5a89aea
 
 
b9dab17
5a89aea
b9dab17
5a89aea
b9dab17
 
 
 
 
5a89aea
b9dab17
5a89aea
b9dab17
 
 
 
5a89aea
b9dab17
 
5a89aea
b9dab17
 
 
5a89aea
 
 
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
import streamlit as st
import os
import random

def get_gifs(directory):
    return [f for f in os.listdir(directory) if f.endswith('.gif')]

def main():
    st.title('Random GIFs')

    directory = './gifs'  # Replace with your directory of GIFs
    gif_files = get_gifs(directory)

    num_rows = len(gif_files) // 3
    if len(gif_files) % 3:
        num_rows += 1

    cols = [st.columns(3) for _ in range(num_rows)]
    
    for i in range(num_rows):
        for j in range(3):
            idx = i*3 + j
            if idx < len(gif_files):
                cols[i][j].image(os.path.join(directory, gif_files[idx]), width=200)

    if st.button('Randomize'):
        random.shuffle(gif_files)
        for i in range(num_rows):
            for j in range(3):
                idx = i*3 + j
                if idx < len(gif_files):
                    cols[i][j].image(os.path.join(directory, gif_files[idx]), width=200)

if __name__ == "__main__":
    main()