GAS17 commited on
Commit
f62d38b
1 Parent(s): 4b7f729

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -0
app.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+
5
+ # Define function to create and display styled table with highlighted header
6
+ def create_styled_table_highlighted_header(data, title):
7
+ df = pd.DataFrame(data)
8
+ fig, ax = plt.subplots(figsize=(12, len(df)*0.7 + 2)) # Adjusting figure size for larger cell height and full image coverage
9
+ ax.axis('tight')
10
+ ax.axis('off')
11
+
12
+ # Add title
13
+ plt.title(title, fontsize=20, weight='bold', fontname='Lato', pad=10)
14
+
15
+ table = ax.table(cellText=df.values, colLabels=df.columns, cellLoc='center', loc='center')
16
+
17
+ # Styling the table
18
+ table.auto_set_font_size(False)
19
+ table.set_fontsize(14)
20
+ table.scale(1.2, 1.5) # Adjusting scale for larger cells
21
+
22
+ # Setting all cells to white
23
+ rows = len(df)
24
+ cols = len(df.columns)
25
+ for i in range(rows):
26
+ for j in range(cols):
27
+ table[(i+1, j)].set_facecolor('white')
28
+
29
+ # Highlighting header
30
+ for j in range(cols):
31
+ table[(0, j)].set_facecolor('#a9a9a9') # Dark grey color
32
+
33
+ # Adjusting column width
34
+ table.auto_set_column_width([0, 1, 2])
35
+
36
+ # Displaying the table as an image
37
+ st.pyplot(fig)
38
+
39
+ # Streamlit app
40
+ st.title('Actividades Culturales')
41
+
42
+ # Form to input activity data
43
+ with st.form("activity_form"):
44
+ title = st.text_input("Título de la actividad")
45
+ days = st.text_area("Días (separados por comas)")
46
+ schedules = st.text_area("Horarios (separados por comas, en el mismo orden que los días)")
47
+ activities = st.text_area("Actividades (separadas por comas, en el mismo orden que los días y horarios)")
48
+ submit_button = st.form_submit_button(label='Crear Tabla')
49
+
50
+ if submit_button:
51
+ # Parse the input data
52
+ days_list = [day.strip() for day in days.split(',')]
53
+ schedules_list = [schedule.strip() for schedule in schedules.split(',')]
54
+ activities_list = [activity.strip() for activity in activities.split(',')]
55
+
56
+ # Create the data dictionary
57
+ data = {
58
+ "Días": days_list,
59
+ "Horario": schedules_list,
60
+ "Actividad": activities_list
61
+ }
62
+
63
+ # Create and display the table
64
+ create_styled_table_highlighted_header(data, title)