ANON-STUDIOS-254 commited on
Commit
3579760
·
verified ·
1 Parent(s): e44748a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -13
app.py CHANGED
@@ -4,19 +4,38 @@ import pandas as pd
4
  from fpdf import FPDF
5
  from datetime import datetime
6
 
7
- # ---------- Inject Custom CSS for a Faded, Existential Background and Glassy Widgets with Architectural Patterns ----------
8
  st.markdown(
9
  """
10
  <style>
11
- /* Faded existential background inspired by Dr. Suss architectural style */
12
  body {
13
- background: linear-gradient(rgba(26,26,26,0.8), rgba(26,26,26,0.8)),
14
  url('https://www.toptal.com/designers/subtlepatterns/patterns/dark_wall.png');
15
  background-size: cover;
16
  background-attachment: fixed;
17
  color: #fff;
 
18
  }
19
- /* Glassy Container with a subtle architectural pattern overlay */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  .glassy-container {
21
  background: rgba(0, 0, 0, 0.5);
22
  background-image: url('https://www.toptal.com/designers/subtlepatterns/patterns/cubes.png');
@@ -33,7 +52,7 @@ st.markdown(
33
  .glassy-container:hover {
34
  transform: scale(1.02);
35
  }
36
- /* Headings and text styling */
37
  h1, h2, h3, p, label {
38
  color: #fff;
39
  text-shadow: 0 0 3px rgba(0,0,0,0.7);
@@ -62,7 +81,7 @@ st.markdown(
62
  .stTextInput>div>input::placeholder {
63
  color: #aaa !important;
64
  }
65
- /* Buttons (Metallic with Glow & Outline) */
66
  .stButton button, .metallic-button {
67
  background: #fff;
68
  color: #000;
@@ -88,10 +107,6 @@ st.markdown(
88
  text-align: center;
89
  border-top: 2px solid #fff;
90
  }
91
- /* Ensure Altair charts are adjusted */
92
- .streamlit-expanderHeader {
93
- font-weight: bold;
94
- }
95
  </style>
96
  """,
97
  unsafe_allow_html=True
@@ -172,7 +187,7 @@ with st.form(key="assessment_form"):
172
  user_responses[q["trait"]] = st.slider(q["question"], 1, 5, 3, key=q["trait"])
173
  submitted = st.form_submit_button("Submit Assessment")
174
  st.markdown("</div>", unsafe_allow_html=True)
175
- st.markdown("</div>", unsafe_allow_html=True) # Close the initial glassy container
176
 
177
  # ---------- Process and Display Results ----------
178
  if submitted and name:
@@ -201,7 +216,7 @@ if submitted and name:
201
  st.markdown("</div>", unsafe_allow_html=True)
202
 
203
  # Multicolored Bar Chart of Scores in a full-width glassy container
204
- st.markdown("<div class='glassy-container'>", unsafe_allow_html=True)
205
  df = pd.DataFrame({
206
  "Trait": list(user_responses.keys()),
207
  "Score": list(user_responses.values())
@@ -218,6 +233,15 @@ if submitted and name:
218
  def generate_pdf_report(name, responses, recs, generated_on):
219
  pdf = FPDF()
220
  pdf.add_page()
 
 
 
 
 
 
 
 
 
221
  # Header with Black background, White text
222
  pdf.set_fill_color(0, 0, 0)
223
  pdf.set_text_color(255, 255, 255)
@@ -240,7 +264,7 @@ if submitted and name:
240
  pdf.set_font("Arial", "", 12)
241
  for trait, score in responses.items():
242
  pdf.multi_cell(0, 10, f"{trait}: {recs[trait][score]}")
243
- # Footer (removed the phrase "LEARN THE CRAFT OF PSYCHOLOGY")
244
  pdf.set_y(-20)
245
  pdf.set_font("Arial", "I", 8)
246
  pdf.cell(0, 10, "Developed by Kabura Kuria - Contact: +254 707 865 934", 0, 0, "C")
 
4
  from fpdf import FPDF
5
  from datetime import datetime
6
 
7
+ # ---------- Inject Custom CSS for a Faded Existential Background and Glassy Widgets ----------
8
  st.markdown(
9
  """
10
  <style>
11
+ /* Faded existential background inspired by Dr. Seuss architectural style */
12
  body {
13
+ background: linear-gradient(rgba(26,26,26,0.8), rgba(26,26,26,0.8)),
14
  url('https://www.toptal.com/designers/subtlepatterns/patterns/dark_wall.png');
15
  background-size: cover;
16
  background-attachment: fixed;
17
  color: #fff;
18
+ font-family: 'Roboto', sans-serif;
19
  }
20
+ /* Full-width glassy container for sections that need to span the width */
21
+ .full-width-glassy {
22
+ width: 100%;
23
+ background: rgba(0, 0, 0, 0.5);
24
+ background-image: url('https://www.toptal.com/designers/subtlepatterns/patterns/cubes.png');
25
+ background-blend-mode: overlay;
26
+ backdrop-filter: blur(12px);
27
+ border: 1px solid transparent;
28
+ border-radius: 10px;
29
+ padding: 2rem;
30
+ margin-bottom: 2rem;
31
+ box-shadow: 0 8px 30px rgba(0,0,0,0.8), 0 0 15px rgba(255,255,255,0.2);
32
+ transition: transform 0.3s ease;
33
+ border-image: linear-gradient(45deg, #fff, #aaa, #fff) 1;
34
+ }
35
+ .full-width-glassy:hover {
36
+ transform: scale(1.02);
37
+ }
38
+ /* Standard glassy container */
39
  .glassy-container {
40
  background: rgba(0, 0, 0, 0.5);
41
  background-image: url('https://www.toptal.com/designers/subtlepatterns/patterns/cubes.png');
 
52
  .glassy-container:hover {
53
  transform: scale(1.02);
54
  }
55
+ /* Headings and text styling with glow */
56
  h1, h2, h3, p, label {
57
  color: #fff;
58
  text-shadow: 0 0 3px rgba(0,0,0,0.7);
 
81
  .stTextInput>div>input::placeholder {
82
  color: #aaa !important;
83
  }
84
+ /* Buttons with metallic glow and outline */
85
  .stButton button, .metallic-button {
86
  background: #fff;
87
  color: #000;
 
107
  text-align: center;
108
  border-top: 2px solid #fff;
109
  }
 
 
 
 
110
  </style>
111
  """,
112
  unsafe_allow_html=True
 
187
  user_responses[q["trait"]] = st.slider(q["question"], 1, 5, 3, key=q["trait"])
188
  submitted = st.form_submit_button("Submit Assessment")
189
  st.markdown("</div>", unsafe_allow_html=True)
190
+ st.markdown("</div>", unsafe_allow_html=True) <!-- End of Title/Description/Form Container -->
191
 
192
  # ---------- Process and Display Results ----------
193
  if submitted and name:
 
216
  st.markdown("</div>", unsafe_allow_html=True)
217
 
218
  # Multicolored Bar Chart of Scores in a full-width glassy container
219
+ st.markdown("<div class='full-width-glassy'>", unsafe_allow_html=True)
220
  df = pd.DataFrame({
221
  "Trait": list(user_responses.keys()),
222
  "Score": list(user_responses.values())
 
233
  def generate_pdf_report(name, responses, recs, generated_on):
234
  pdf = FPDF()
235
  pdf.add_page()
236
+ # Set a decorative background in the PDF (requires pdf_background.png in working directory)
237
+ try:
238
+ pdf.image("pdf_background.png", x=0, y=0, w=pdf.w, h=pdf.h)
239
+ except Exception as e:
240
+ pass # If not found, continue without background
241
+ # Draw a decorative border
242
+ pdf.set_draw_color(180, 180, 180)
243
+ pdf.rect(5, 5, pdf.w - 10, pdf.h - 10)
244
+
245
  # Header with Black background, White text
246
  pdf.set_fill_color(0, 0, 0)
247
  pdf.set_text_color(255, 255, 255)
 
264
  pdf.set_font("Arial", "", 12)
265
  for trait, score in responses.items():
266
  pdf.multi_cell(0, 10, f"{trait}: {recs[trait][score]}")
267
+ # Footer (removed extra phrase)
268
  pdf.set_y(-20)
269
  pdf.set_font("Arial", "I", 8)
270
  pdf.cell(0, 10, "Developed by Kabura Kuria - Contact: +254 707 865 934", 0, 0, "C")