File size: 2,187 Bytes
f62d38b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt

# Define function to create and display styled table with highlighted header
def create_styled_table_highlighted_header(data, title):
    df = pd.DataFrame(data)
    fig, ax = plt.subplots(figsize=(12, len(df)*0.7 + 2))  # Adjusting figure size for larger cell height and full image coverage
    ax.axis('tight')
    ax.axis('off')

    # Add title
    plt.title(title, fontsize=20, weight='bold', fontname='Lato', pad=10)

    table = ax.table(cellText=df.values, colLabels=df.columns, cellLoc='center', loc='center')

    # Styling the table
    table.auto_set_font_size(False)
    table.set_fontsize(14)
    table.scale(1.2, 1.5)  # Adjusting scale for larger cells

    # Setting all cells to white
    rows = len(df)
    cols = len(df.columns)
    for i in range(rows):
        for j in range(cols):
            table[(i+1, j)].set_facecolor('white')

    # Highlighting header
    for j in range(cols):
        table[(0, j)].set_facecolor('#a9a9a9')  # Dark grey color

    # Adjusting column width
    table.auto_set_column_width([0, 1, 2])

    # Displaying the table as an image
    st.pyplot(fig)

# Streamlit app
st.title('Actividades Culturales')

# Form to input activity data
with st.form("activity_form"):
    title = st.text_input("Título de la actividad")
    days = st.text_area("Días (separados por comas)")
    schedules = st.text_area("Horarios (separados por comas, en el mismo orden que los días)")
    activities = st.text_area("Actividades (separadas por comas, en el mismo orden que los días y horarios)")
    submit_button = st.form_submit_button(label='Crear Tabla')

if submit_button:
    # Parse the input data
    days_list = [day.strip() for day in days.split(',')]
    schedules_list = [schedule.strip() for schedule in schedules.split(',')]
    activities_list = [activity.strip() for activity in activities.split(',')]
    
    # Create the data dictionary
    data = {
        "Días": days_list,
        "Horario": schedules_list,
        "Actividad": activities_list
    }
    
    # Create and display the table
    create_styled_table_highlighted_header(data, title)