ombhojane commited on
Commit
58e4d25
·
verified ·
1 Parent(s): f4f018e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -12,19 +12,20 @@ def main():
12
  st.header("Meme Template Gallery")
13
  meme_templates = [f for f in os.listdir("meme_templates") if f.endswith(('.png', '.jpg', '.jpeg'))]
14
 
15
- # Create a 4-column layout
16
- cols = st.columns(4)
17
-
18
  # Use session state to store the selected template
19
  if 'selected_template' not in st.session_state:
20
  st.session_state.selected_template = None
21
 
 
 
 
22
  for idx, template in enumerate(meme_templates):
23
  col = cols[idx % 4]
24
  image_path = os.path.join("meme_templates", template)
25
  with Image.open(image_path) as img:
26
- if col.image(img, caption=template, use_column_width=True):
27
- st.session_state.selected_template = template
 
28
 
29
  # Display selected template and generate meme
30
  if st.session_state.selected_template:
 
12
  st.header("Meme Template Gallery")
13
  meme_templates = [f for f in os.listdir("meme_templates") if f.endswith(('.png', '.jpg', '.jpeg'))]
14
 
 
 
 
15
  # Use session state to store the selected template
16
  if 'selected_template' not in st.session_state:
17
  st.session_state.selected_template = None
18
 
19
+ # Create a 4-column layout
20
+ cols = st.columns(4)
21
+
22
  for idx, template in enumerate(meme_templates):
23
  col = cols[idx % 4]
24
  image_path = os.path.join("meme_templates", template)
25
  with Image.open(image_path) as img:
26
+ col.image(img, use_column_width=True)
27
+ if col.button(f"Select {template}", key=f"btn_{template}"):
28
+ st.session_state.selected_template = template
29
 
30
  # Display selected template and generate meme
31
  if st.session_state.selected_template: