awacke1 commited on
Commit
0cd2e05
Β·
verified Β·
1 Parent(s): ddf1347

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -622,37 +622,39 @@ def create_media_gallery():
622
  # Here you could integrate with image generation API
623
  st.write(f"Generated scene description for {bike_name}:")
624
  st.write(prompt)
625
-
626
  def display_file_manager():
627
- """Display file management sidebar."""
628
  st.sidebar.title("πŸ“ File Management")
629
 
630
  all_files = glob.glob("*.md")
631
  all_files.sort(reverse=True)
632
 
633
- if st.sidebar.button("πŸ—‘ Delete All"):
 
634
  for file in all_files:
635
  os.remove(file)
636
  st.rerun()
637
 
638
- if st.sidebar.button("⬇️ Download All"):
 
639
  zip_file = create_zip_of_files(all_files)
640
  st.sidebar.markdown(get_download_link(zip_file), unsafe_allow_html=True)
641
 
 
642
  for file in all_files:
643
  col1, col2, col3, col4 = st.sidebar.columns([1,3,1,1])
644
  with col1:
645
- if st.button("🌐", key="view_"+file):
646
  st.session_state.current_file = file
647
  st.session_state.file_content = load_file(file)
648
  with col2:
649
  st.markdown(get_download_link(file), unsafe_allow_html=True)
650
  with col3:
651
- if st.button("πŸ“‚", key="edit_"+file):
652
  st.session_state.current_file = file
653
  st.session_state.file_content = load_file(file)
654
  with col4:
655
- if st.button("πŸ—‘", key="delete_"+file):
656
  os.remove(file)
657
  st.rerun()
658
 
 
622
  # Here you could integrate with image generation API
623
  st.write(f"Generated scene description for {bike_name}:")
624
  st.write(prompt)
 
625
  def display_file_manager():
626
+ """Display file management sidebar with unique button keys."""
627
  st.sidebar.title("πŸ“ File Management")
628
 
629
  all_files = glob.glob("*.md")
630
  all_files.sort(reverse=True)
631
 
632
+ # Add unique key to Delete All button
633
+ if st.sidebar.button("πŸ—‘ Delete All", key="delete_all_files"):
634
  for file in all_files:
635
  os.remove(file)
636
  st.rerun()
637
 
638
+ # Add unique key to Download All button
639
+ if st.sidebar.button("⬇️ Download All", key="download_all_files"):
640
  zip_file = create_zip_of_files(all_files)
641
  st.sidebar.markdown(get_download_link(zip_file), unsafe_allow_html=True)
642
 
643
+ # Generate unique keys for each file's buttons using file name and action
644
  for file in all_files:
645
  col1, col2, col3, col4 = st.sidebar.columns([1,3,1,1])
646
  with col1:
647
+ if st.button("🌐", key=f"view_{file}"):
648
  st.session_state.current_file = file
649
  st.session_state.file_content = load_file(file)
650
  with col2:
651
  st.markdown(get_download_link(file), unsafe_allow_html=True)
652
  with col3:
653
+ if st.button("πŸ“‚", key=f"edit_{file}"):
654
  st.session_state.current_file = file
655
  st.session_state.file_content = load_file(file)
656
  with col4:
657
+ if st.button("πŸ—‘", key=f"delete_single_{file}"):
658
  os.remove(file)
659
  st.rerun()
660