Spaces:
Build error
Build error
| import streamlit as st | |
| import pandas as pd | |
| import os | |
| import tempfile | |
| import matplotlib.pyplot as plt | |
| from matplotlib.backends.backend_pdf import PdfPages | |
| def show(): | |
| st.title("馃敡 Opciones") | |
| def generar_pdf(df, titulo, filename): | |
| pdf_path = os.path.join(tempfile.gettempdir(), filename) | |
| with PdfPages(pdf_path) as pdf: | |
| plt.figure() | |
| plt.axis('tight') | |
| plt.axis('off') | |
| plt.table(cellText=df.values, colLabels=df.columns, cellLoc='center', loc='center') | |
| plt.title(titulo) | |
| pdf.savefig() | |
| plt.close() | |
| return pdf_path | |
| if st.button("Comprar"): | |
| st.success("Funci贸n de compra en desarrollo...") | |
| if st.button("Descargar PDF"): | |
| if 'pedidos' in st.session_state and st.session_state.pedidos: | |
| pedidos_df = pd.DataFrame(st.session_state.pedidos) | |
| pdf_file = generar_pdf(pedidos_df, "Pedidos de Saz贸n Burger", "pedidos.pdf") | |
| st.download_button( | |
| label="馃摜 Descargar PDF", | |
| data=open(pdf_file, 'rb').read(), | |
| file_name="pedidos.pdf", | |
| mime="application/pdf" | |
| ) | |
| else: | |
| st.warning("No hay pedidos para descargar.") | |