Spaces:
Sleeping
Sleeping
Yash Sharma
commited on
Commit
•
f2f00d5
1
Parent(s):
24f6817
Committing changes to pages directory
Browse files- pages/.streamlit/config.toml +6 -0
- pages/About.py +14 -0
- pages/CBTAnalysis.py +123 -0
- pages/DailyMoodTracker.py +760 -0
- pages/Graphs.py +24 -0
- pages/Home.py +249 -0
- pages/Mindfulness.py +97 -0
pages/.streamlit/config.toml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
primaryColor="#F63366"
|
3 |
+
backgroundColor="#FFFFFF"
|
4 |
+
secondaryBackgroundColor="#F0F2F6"
|
5 |
+
textColor="#262730"
|
6 |
+
font="sans serif"
|
pages/About.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import streamlit as st
|
2 |
+
# from streamlit.components.v1 import html
|
3 |
+
|
4 |
+
# # Define your javascript
|
5 |
+
# my_js = """
|
6 |
+
# alert("Hola mundo");
|
7 |
+
# """
|
8 |
+
|
9 |
+
# # Wrapt the javascript as html code
|
10 |
+
# my_html = f"<script>{my_js}</script>"
|
11 |
+
|
12 |
+
# # Execute your app
|
13 |
+
# st.title("Javascript example")
|
14 |
+
# html(my_html)
|
pages/CBTAnalysis.py
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from streamlit.components.v1 import html
|
4 |
+
class Therapy:
|
5 |
+
def __init__(self, condition):
|
6 |
+
self.condition = condition
|
7 |
+
self.answers = {}
|
8 |
+
self.weights = {}
|
9 |
+
|
10 |
+
def ask_questions(self, my_questions):
|
11 |
+
for key, question in my_questions.items():
|
12 |
+
unique_key = f"{self.condition}_{key}" # Create a unique key
|
13 |
+
st.write(f"{key}) {question}")
|
14 |
+
answer = st.text_input(f"Answer for {key}:", key=unique_key) # Pass the unique key
|
15 |
+
rating = st.slider(f"Rate your answer for {key} (1-10):", 1, 10, 5) # Slider for ratings
|
16 |
+
self.answers[unique_key] = answer
|
17 |
+
self.weights[unique_key] = rating
|
18 |
+
|
19 |
+
|
20 |
+
def predict_problem_rating(self):
|
21 |
+
total_weight = sum(self.weights.values())
|
22 |
+
if total_weight == 0:
|
23 |
+
st.warning("Warning: Total weight is zero. Please make sure to assign weights to the questions.")
|
24 |
+
return None
|
25 |
+
|
26 |
+
weighted_sum = sum(self.weights[key] for key in self.weights if key in self.answers)
|
27 |
+
|
28 |
+
average_score = weighted_sum / 10
|
29 |
+
return average_score
|
30 |
+
|
31 |
+
def main():
|
32 |
+
st.markdown(
|
33 |
+
"""
|
34 |
+
<style>
|
35 |
+
.main {
|
36 |
+
background-image: radial-gradient(circle, #f902da, #f363e6, #ff5900);
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
.title {
|
41 |
+
color: #f0f0f0;
|
42 |
+
font-size: 48px;
|
43 |
+
text-align: center;
|
44 |
+
font-weight: bold;
|
45 |
+
}
|
46 |
+
.st-bx{
|
47 |
+
color: #0d0101;
|
48 |
+
background-color: #f0f0f0;
|
49 |
+
}
|
50 |
+
.st-bt{
|
51 |
+
background-color: #f0f0f0;
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
.css-c2zpwa:hover,css-c2zpwa:active,css-c2zpwa:focus{
|
56 |
+
background: #ffffff;
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
</style>
|
61 |
+
""",
|
62 |
+
unsafe_allow_html=True)
|
63 |
+
|
64 |
+
st.markdown('<p class="title">CBT Questionaire</p>', unsafe_allow_html=True)
|
65 |
+
|
66 |
+
conditions = ["Intro-therapy", "ADHD", "PTSD", "BPD"]
|
67 |
+
selected_condition = st.selectbox("Select for a condition:", conditions)
|
68 |
+
|
69 |
+
therapy = Therapy(selected_condition)
|
70 |
+
|
71 |
+
if selected_condition == "Intro-therapy":
|
72 |
+
my_questions = {
|
73 |
+
1: "What type of Emotions are you experiencing?",
|
74 |
+
2: "At what time do you sleep?",
|
75 |
+
3: "How do you interact with family or friends?",
|
76 |
+
4: "At what time do you wake up?",
|
77 |
+
5: "What are your goals?",
|
78 |
+
6: "How do you see people around?",
|
79 |
+
7: "How much do you eat?"
|
80 |
+
}
|
81 |
+
|
82 |
+
if selected_condition == "ADHD":
|
83 |
+
my_questions = {
|
84 |
+
1: "What are some common challenges you face in you?",
|
85 |
+
2: "Can you identify specific situations where you feel your ADHD symptoms are most problematic or disruptive?",
|
86 |
+
3: "How do you currently perceive your ADHD symptoms? Are there any negative thought patterns associated with them?",
|
87 |
+
4: "Have you noticed any recurring thought patterns or beliefs about yourself and your abilities that might affect your self-esteem or motivation?",
|
88 |
+
5: "How do you typically react when you realize you've made a mistake or forgotten something important due to your ADHD symptoms?",
|
89 |
+
6: "Are there specific tasks or activities that you tend to procrastinate on? What thoughts or feelings arise when you're faced with these tasks?",
|
90 |
+
7: "Can you recall times when you've successfully managed your ADHD symptoms or used effective strategies? What was different about those situations?"
|
91 |
+
}
|
92 |
+
|
93 |
+
if selected_condition == "PTSD":
|
94 |
+
my_questions = {
|
95 |
+
1: "Does your intuition tell you that what you remember is or was real, no matter how hard you try to disbelieve it?",
|
96 |
+
2: "Does the memory keep returning, even after you try to forget it?",
|
97 |
+
3: "Does the memory fit with your habits, fears, behaviors, symptoms, health problems, or the facts of your life as you know them?",
|
98 |
+
4: "Is your memory of certain aspects of the traumatic event clear?",
|
99 |
+
5: "Are certain aspects of the event cloudy?",
|
100 |
+
6: "Does your memory come in fragments?",
|
101 |
+
7: "Does remembering anything about the event bring you a sense of relief, understanding, or increased strength?"
|
102 |
+
}
|
103 |
+
|
104 |
+
if selected_condition == "BPD":
|
105 |
+
my_questions = {
|
106 |
+
1: "Are there any recurring negative thoughts or self-criticisms you've been experiencing?",
|
107 |
+
2: "Can you identify any cognitive distortions in your thinking?",
|
108 |
+
3: "Can you describe the intensity and nature of your emotions?",
|
109 |
+
4: "What actions or behaviors have you engaged in recently that you'd like to discuss?",
|
110 |
+
5: "Are there any strategies or skills you've been using to manage your emotions?",
|
111 |
+
6: "Can you share any recent experiences or conflicts in your relationships?",
|
112 |
+
7: "Are there any conflicts or inconsistencies in your self-image that you'd like to explore?"
|
113 |
+
}
|
114 |
+
|
115 |
+
therapy.ask_questions(my_questions)
|
116 |
+
if st.button("Submit"):
|
117 |
+
predicted_rating = therapy.predict_problem_rating()
|
118 |
+
st.write(f"Predicted Problem Rating: {predicted_rating:.2f} (on a scale of 1-10)")
|
119 |
+
st.write("If score is below 5 please have a chat with our bot, it is urgent")
|
120 |
+
|
121 |
+
if __name__ == "__main__":
|
122 |
+
main()
|
123 |
+
|
pages/DailyMoodTracker.py
ADDED
@@ -0,0 +1,760 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# # import streamlit as st
|
2 |
+
# # import pandas as pd
|
3 |
+
# # from datetime import datetime
|
4 |
+
# # from plyer import notification
|
5 |
+
|
6 |
+
# # class MentalHealthTracker:
|
7 |
+
# # def __init__(self, user_id):
|
8 |
+
# # self.user_id = user_id
|
9 |
+
# # self.daily_answers = {}
|
10 |
+
# # self.weekly_suggestions = {}
|
11 |
+
|
12 |
+
# # def ask_daily_questions(self, daily_questions):
|
13 |
+
# # today_date = datetime.now().strftime("%Y-%m-%d")
|
14 |
+
# # st.subheader(f"Daily Questions - {today_date}")
|
15 |
+
|
16 |
+
# # for key, question in daily_questions.items():
|
17 |
+
# # unique_key = f"{today_date}_{key}"
|
18 |
+
# # st.write(f"{key}) {question}")
|
19 |
+
# # answer = st.text_input(f"Answer for {key}:", key=unique_key)
|
20 |
+
# # self.daily_answers[unique_key] = answer
|
21 |
+
|
22 |
+
# # def save_daily_answers_to_csv(self, filename):
|
23 |
+
# # df = pd.DataFrame(list(self.daily_answers.items()), columns=['Question ID', 'Answer'])
|
24 |
+
# # df.to_csv(filename, index=False)
|
25 |
+
# # st.success(f"Daily Answers saved to {filename}")
|
26 |
+
|
27 |
+
# # def set_daily_reminder(self, reminder_time):
|
28 |
+
# # # Set a daily reminder using plyer
|
29 |
+
# # now = datetime.now()
|
30 |
+
# # notification_time = datetime.strptime(reminder_time, "%H:%M")
|
31 |
+
|
32 |
+
# # # Calculate time until the next daily reminder
|
33 |
+
# # time_until_reminder = (datetime.combine(now.date(), notification_time.time()) - now).total_seconds()
|
34 |
+
|
35 |
+
# # # Schedule the reminder
|
36 |
+
# # notification.notify(
|
37 |
+
# # title=f"Daily Reminder",
|
38 |
+
# # message="Don't forget to answer your daily mental health questions!",
|
39 |
+
# # timeout=int(time_until_reminder),
|
40 |
+
# # )
|
41 |
+
|
42 |
+
# # def main():
|
43 |
+
# # st.markdown(
|
44 |
+
# # """
|
45 |
+
# # <style>
|
46 |
+
# # .main {
|
47 |
+
# # background-color: #14839f; /* Set your desired background color */
|
48 |
+
# # }
|
49 |
+
|
50 |
+
# # .title {
|
51 |
+
# # color: #f0f0f0;
|
52 |
+
# # font-size: 48px;
|
53 |
+
# # text-align: center;
|
54 |
+
# # font-weight: bold;
|
55 |
+
# # }
|
56 |
+
# # .st-bx{
|
57 |
+
# # color: #0d0101;
|
58 |
+
# # }
|
59 |
+
# # .st-bt{
|
60 |
+
# # background-color: #f0f0f0;
|
61 |
+
# # }
|
62 |
+
# # </style>
|
63 |
+
# # """,
|
64 |
+
# # unsafe_allow_html=True)
|
65 |
+
# # st.markdown('<p class="title">Mental Health Tracker App</p>', unsafe_allow_html=True)
|
66 |
+
|
67 |
+
|
68 |
+
# # # User ID
|
69 |
+
# # user_id = st.text_input('Enter User ID:', key='user_id')
|
70 |
+
|
71 |
+
|
72 |
+
# # # Create MentalHealthTracker instance
|
73 |
+
# # mental_health_tracker = MentalHealthTracker(user_id)
|
74 |
+
|
75 |
+
# # # Daily Questions
|
76 |
+
# # daily_questions = {
|
77 |
+
# # 1: "How would you rate your overall mood today?",
|
78 |
+
# # 2: "Did you engage in any physical activity today?",
|
79 |
+
# # 3: "What is one positive thing that happened today?",
|
80 |
+
# # 4: "Is there anything on your mind that you'd like to share?",
|
81 |
+
# # # Add more daily questions as needed
|
82 |
+
# # }
|
83 |
+
|
84 |
+
# # # Set a daily reminder
|
85 |
+
# # reminder_time = st.text_input("Set a daily reminder time (HH:MM):", "09:00")
|
86 |
+
# # mental_health_tracker.set_daily_reminder(reminder_time)
|
87 |
+
|
88 |
+
# # # Ask daily questions
|
89 |
+
# # mental_health_tracker.ask_daily_questions(daily_questions)
|
90 |
+
|
91 |
+
# # if st.button("Save Daily Answers"):
|
92 |
+
# # st.button("Save Daily Answers", key="save_button")
|
93 |
+
# # mental_health_tracker.save_daily_answers_to_csv(f"{user_id}_daily_answers.csv")
|
94 |
+
|
95 |
+
# # if __name__ == "__main__":
|
96 |
+
# # main()
|
97 |
+
# # import streamlit as st
|
98 |
+
# # from datetime import datetime
|
99 |
+
# # from deta import Deta
|
100 |
+
|
101 |
+
|
102 |
+
# # # Load the environment variables
|
103 |
+
# # DETA_KEY = "d0z8gryt9dj_HMVcfkbW7ZYYVeyz3xakbf48ZZGAxUtp"
|
104 |
+
|
105 |
+
# # # Initialize with a project key
|
106 |
+
# # deta = Deta(DETA_KEY)
|
107 |
+
# # my_db = deta.Base("data_reports")
|
108 |
+
# # class MentalHealthTracker:
|
109 |
+
# # def __init__(self, user_id):
|
110 |
+
# # self.user_id = user_id
|
111 |
+
# # self.daily_answers = {}
|
112 |
+
|
113 |
+
# # def ask_daily_questions(self, daily_questions):
|
114 |
+
# # today_date = datetime.now().strftime("%Y-%m-%d")
|
115 |
+
# # st.subheader(f"Daily Questions - {today_date}")
|
116 |
+
|
117 |
+
# # for key, question in daily_questions.items():
|
118 |
+
# # unique_key = f"{today_date}_{key}"
|
119 |
+
# # st.write(f"{key}) {question}")
|
120 |
+
# # answer = st.text_input(f"Answer for {key}:", key=unique_key)
|
121 |
+
# # self.daily_answers[unique_key] = answer
|
122 |
+
|
123 |
+
# # def save_daily_answers_to_deta(self, deta_base):
|
124 |
+
# # data_to_insert = {
|
125 |
+
# # "Timestamp": datetime.now(),
|
126 |
+
# # "Activity": self.daily_answers.get("activity", ""),
|
127 |
+
# # "ID": self.daily_answers.get("id_value", ""),
|
128 |
+
# # "Positive": self.daily_answers.get("positive", ""),
|
129 |
+
# # "Mood": self.daily_answers.get("mood", ""),
|
130 |
+
# # }
|
131 |
+
|
132 |
+
# # # Insert data into Deta Base
|
133 |
+
# # result = my_db.put(data_to_insert)
|
134 |
+
|
135 |
+
# # # Display the result
|
136 |
+
# # st.success("Daily Answers saved successfully to Deta Base:")
|
137 |
+
# # st.write(result)
|
138 |
+
|
139 |
+
|
140 |
+
|
141 |
+
# # def main():
|
142 |
+
# # st.markdown(
|
143 |
+
# # """
|
144 |
+
# # <style>
|
145 |
+
# # .main {
|
146 |
+
# # background-color: #14839f; /* Set your desired background color */
|
147 |
+
# # }
|
148 |
+
|
149 |
+
# # .title {
|
150 |
+
# # color: #f0f0f0;
|
151 |
+
# # font-size: 48px;
|
152 |
+
# # text-align: center;
|
153 |
+
# # font-weight: bold;
|
154 |
+
# # }
|
155 |
+
# # .st-bx{
|
156 |
+
# # color: #0d0101;
|
157 |
+
# # }
|
158 |
+
# # .st-bt{
|
159 |
+
# # background-color: #f0f0f0;
|
160 |
+
# # }
|
161 |
+
# # </style>
|
162 |
+
# # """,
|
163 |
+
# # unsafe_allow_html=True)
|
164 |
+
# # st.markdown('<p class="title">Mental Health Tracker App</p>', unsafe_allow_html=True)
|
165 |
+
|
166 |
+
# # # User ID
|
167 |
+
# # user_id = st.text_input('Enter User ID:', key='user_id')
|
168 |
+
|
169 |
+
# # # Create Deta Base instance
|
170 |
+
# # deta_base = deta.Base("mental_health_data")
|
171 |
+
|
172 |
+
# # # Create MentalHealthTracker instance
|
173 |
+
# # mental_health_tracker = MentalHealthTracker(user_id)
|
174 |
+
|
175 |
+
# # # Daily Questions
|
176 |
+
# # daily_questions = {
|
177 |
+
# # "activity": "What activity did you engage in today?",
|
178 |
+
# # "id_value": "Enter an ID value:",
|
179 |
+
# # "positive": "Did you experience something positive today?",
|
180 |
+
# # "mood": "Rate your mood on a scale of 1 to 10:",
|
181 |
+
# # # Add more daily questions as needed
|
182 |
+
# # }
|
183 |
+
|
184 |
+
# # # Set a daily reminder
|
185 |
+
# # reminder_time = st.text_input("Set a daily reminder time (HH:MM):", "09:00")
|
186 |
+
# # mental_health_tracker.set_daily_reminder(reminder_time)
|
187 |
+
|
188 |
+
# # # Ask daily questions
|
189 |
+
# # mental_health_tracker.ask_daily_questions(daily_questions)
|
190 |
+
|
191 |
+
# # if st.button("Save Daily Answers"):
|
192 |
+
# # st.button("Save Daily Answers", key="save_button")
|
193 |
+
# # mental_health_tracker.save_daily_answers_to_deta(deta_base)
|
194 |
+
|
195 |
+
# # if __name__ == "__main__":
|
196 |
+
# # main()
|
197 |
+
# # import streamlit as st
|
198 |
+
# # from datetime import datetime
|
199 |
+
# # from deta import Deta
|
200 |
+
|
201 |
+
# # # Load the environment variables
|
202 |
+
# # DETA_KEY = "d0z8gryt9dj_HMVcfkbW7ZYYVeyz3xakbf48ZZGAxUtp"
|
203 |
+
|
204 |
+
# # # Initialize with a project key
|
205 |
+
# # deta = Deta(DETA_KEY)
|
206 |
+
# # my_db = deta.Base("data_reports")
|
207 |
+
|
208 |
+
# # class MentalHealthTracker:
|
209 |
+
# # def __init__(self, user_id):
|
210 |
+
# # self.user_id = user_id
|
211 |
+
# # self.daily_answers = {}
|
212 |
+
|
213 |
+
# # def ask_daily_questions(self, daily_questions):
|
214 |
+
# # today_date = datetime.now().strftime("%Y-%m-%d")
|
215 |
+
# # st.subheader(f"Daily Questions - {today_date}")
|
216 |
+
|
217 |
+
# # for key, question in daily_questions.items():
|
218 |
+
# # unique_key = f"{today_date}_{key}"
|
219 |
+
# # st.write(f"{key}) {question}")
|
220 |
+
# # answer = st.text_input(f"Answer for {key}:", key=unique_key)
|
221 |
+
# # self.daily_answers[unique_key] = answer
|
222 |
+
|
223 |
+
# # def save_daily_answers_to_deta(self, deta_base):
|
224 |
+
# # timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
225 |
+
|
226 |
+
# # data_to_insert = {
|
227 |
+
# # "Timestamp": timestamp,
|
228 |
+
# # "Activity": self.daily_answers.get("activity", ""),
|
229 |
+
# # "ID": self.daily_answers.get("id_value", ""),
|
230 |
+
# # "Positive": self.daily_answers.get("positive", ""),
|
231 |
+
# # "Mood": self.daily_answers.get("mood", ""),
|
232 |
+
# # }
|
233 |
+
|
234 |
+
# # # Insert data into Deta Base
|
235 |
+
# # result = my_db.put(data_to_insert)
|
236 |
+
|
237 |
+
# # # Display the result
|
238 |
+
# # st.success("Daily Answers saved successfully to Deta Base:")
|
239 |
+
# # st.write(result)
|
240 |
+
|
241 |
+
|
242 |
+
# # def main():
|
243 |
+
# # st.markdown(
|
244 |
+
# # """
|
245 |
+
# # <style>
|
246 |
+
# # .main {
|
247 |
+
# # background-color: #14839f; /* Set your desired background color */
|
248 |
+
# # }
|
249 |
+
|
250 |
+
# # .title {
|
251 |
+
# # color: #f0f0f0;
|
252 |
+
# # font-size: 48px;
|
253 |
+
# # text-align: center;
|
254 |
+
# # font-weight: bold;
|
255 |
+
# # }
|
256 |
+
# # .st-bx{
|
257 |
+
# # color: #0d0101;
|
258 |
+
# # }
|
259 |
+
# # .st-bt{
|
260 |
+
# # background-color: #f0f0f0;
|
261 |
+
# # }
|
262 |
+
# # </style>
|
263 |
+
# # """,
|
264 |
+
# # unsafe_allow_html=True)
|
265 |
+
# # st.markdown('<p class="title">Mental Health Tracker App</p>', unsafe_allow_html=True)
|
266 |
+
|
267 |
+
# # # User ID
|
268 |
+
# # user_id = st.text_input('Enter User ID:', key='user_id')
|
269 |
+
|
270 |
+
# # # Create MentalHealthTracker instance
|
271 |
+
# # mental_health_tracker = MentalHealthTracker(user_id)
|
272 |
+
|
273 |
+
# # # Daily Questions
|
274 |
+
# # daily_questions = {
|
275 |
+
# # "activity": "What activity did you engage in today?",
|
276 |
+
# # "id_value": "Enter an ID value:",
|
277 |
+
# # "positive": "Did you experience something positive today?",
|
278 |
+
# # "mood": "Rate your mood on a scale of 1 to 10:",
|
279 |
+
# # # Add more daily questions as needed
|
280 |
+
# # }
|
281 |
+
|
282 |
+
# # # Ask daily questions
|
283 |
+
# # mental_health_tracker.ask_daily_questions(daily_questions)
|
284 |
+
|
285 |
+
# # if st.button("Save Daily Answers"):
|
286 |
+
# # st.button("Save Daily Answers", key="save_button")
|
287 |
+
# # mental_health_tracker.save_daily_answers_to_deta(my_db)
|
288 |
+
|
289 |
+
# # if __name__ == "__main__":
|
290 |
+
# # main()
|
291 |
+
# import streamlit as st
|
292 |
+
# from datetime import datetime
|
293 |
+
# from deta import Deta
|
294 |
+
|
295 |
+
# # Load the environment variables
|
296 |
+
# DETA_KEY = "d0z8gryt9dj_HMVcfkbW7ZYYVeyz3xakbf48ZZGAxUtp"
|
297 |
+
|
298 |
+
# # Initialize with a project key
|
299 |
+
# deta = Deta(DETA_KEY)
|
300 |
+
# my_db = deta.Base("data_reports")
|
301 |
+
|
302 |
+
# class MentalHealthTracker:
|
303 |
+
# def __init__(self, user_id):
|
304 |
+
# self.user_id = user_id
|
305 |
+
# self.daily_answers = {}
|
306 |
+
|
307 |
+
# def ask_daily_questions(self, daily_questions):
|
308 |
+
# today_date = datetime.now().strftime("%Y-%m-%d")
|
309 |
+
# st.subheader(f"Daily Questions - {today_date}")
|
310 |
+
|
311 |
+
# for key, question in daily_questions.items():
|
312 |
+
# unique_key = f"{today_date}_{key}"
|
313 |
+
# st.write(f"{key}) {question}")
|
314 |
+
# answer = st.text_input(f"Answer for {key}:", key=unique_key)
|
315 |
+
# self.daily_answers[unique_key] = answer
|
316 |
+
|
317 |
+
# def save_daily_answers_to_deta(self, my_db):
|
318 |
+
# timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
319 |
+
|
320 |
+
# data_to_insert = {
|
321 |
+
# "Timestamp": timestamp,
|
322 |
+
# "Activity": self.daily_answers.get("activity", ""),
|
323 |
+
# "ID": self.daily_answers.get("id_value", ""),
|
324 |
+
# "Positive": self.daily_answers.get("positive", ""),
|
325 |
+
# "Mood": self.daily_answers.get("mood", ""),
|
326 |
+
# }
|
327 |
+
|
328 |
+
# # Debugging statements
|
329 |
+
# st.write("Data to insert:")
|
330 |
+
# st.write(data_to_insert)
|
331 |
+
|
332 |
+
# # Insert data into Deta Base
|
333 |
+
# result = my_db.put(data_to_insert)
|
334 |
+
|
335 |
+
# # Debugging statements
|
336 |
+
|
337 |
+
# # Display the result
|
338 |
+
# st.success("Daily Answers saved successfully to Deta Base:")
|
339 |
+
# st.write(result)
|
340 |
+
|
341 |
+
# def main():
|
342 |
+
# st.markdown(
|
343 |
+
# """
|
344 |
+
# <style>
|
345 |
+
# .main {
|
346 |
+
# background-color: #14839f; /* Set your desired background color */
|
347 |
+
# }
|
348 |
+
|
349 |
+
# .title {
|
350 |
+
# color: #f0f0f0;
|
351 |
+
# font-size: 48px;
|
352 |
+
# text-align: center;
|
353 |
+
# font-weight: bold;
|
354 |
+
# }
|
355 |
+
# .st-bx{
|
356 |
+
# color: #0d0101;
|
357 |
+
# }
|
358 |
+
# .st-bt{
|
359 |
+
# background-color: #f0f0f0;
|
360 |
+
# }
|
361 |
+
# </style>
|
362 |
+
# """,
|
363 |
+
# unsafe_allow_html=True)
|
364 |
+
# st.markdown('<p class="title">Mental Health Tracker App</p>', unsafe_allow_html=True)
|
365 |
+
|
366 |
+
# # Use st.session_state to persist the object across runs
|
367 |
+
# if 'mental_health_tracker' not in st.session_state:
|
368 |
+
# user_id = st.text_input('Enter User ID:', key='user_id')
|
369 |
+
# st.session_state.mental_health_tracker = MentalHealthTracker(user_id)
|
370 |
+
|
371 |
+
# # Create MentalHealthTracker instance
|
372 |
+
# mental_health_tracker = st.session_state.mental_health_tracker
|
373 |
+
|
374 |
+
# # Daily Questions
|
375 |
+
# daily_questions = {
|
376 |
+
# "activity": "What activity did you engage in today?",
|
377 |
+
# "id_value": "Enter an ID value:",
|
378 |
+
# "positive": "Did you experience something positive today?",
|
379 |
+
# "mood": "Rate your mood on a scale of 1 to 10:",
|
380 |
+
# # Add more daily questions as needed
|
381 |
+
# }
|
382 |
+
|
383 |
+
# # Ask daily questions
|
384 |
+
# mental_health_tracker.ask_daily_questions(daily_questions)
|
385 |
+
|
386 |
+
# if st.button("Save Daily Answers"):
|
387 |
+
# st.button("Save Daily Answers", key="save_button")
|
388 |
+
# mental_health_tracker.save_daily_answers_to_deta(my_db)
|
389 |
+
|
390 |
+
# if __name__ == "__main__":
|
391 |
+
# main()
|
392 |
+
# import streamlit as st
|
393 |
+
# from datetime import datetime
|
394 |
+
# from deta import Deta
|
395 |
+
|
396 |
+
# # Load the environment variables
|
397 |
+
# DETA_KEY = "d0z8gryt9dj_HMVcfkbW7ZYYVeyz3xakbf48ZZGAxUtp"
|
398 |
+
|
399 |
+
# # Initialize with a project key
|
400 |
+
# deta = Deta(DETA_KEY)
|
401 |
+
|
402 |
+
# # Create Deta Base instance
|
403 |
+
# my_db = deta.Base("data_reports")
|
404 |
+
|
405 |
+
# # Ask questions before entries
|
406 |
+
# st.header("Daily Entry Questions")
|
407 |
+
|
408 |
+
|
409 |
+
# # Dynamic input fields for user data
|
410 |
+
# st.subheader("Entry")
|
411 |
+
# activity = st.text_input(f"What activity did you engage in today?", value="")
|
412 |
+
# user_id = st.text_input(f"Enter an ID value: (User ID)", value="")
|
413 |
+
# positive = st.text_input(f"Did you experience something positive today?", value="")
|
414 |
+
# mood = st.text_input(f"Rate your mood on a scale of 1 to 10:", value="")
|
415 |
+
|
416 |
+
# # Add current date and time to the entry
|
417 |
+
# timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
418 |
+
# entry = {
|
419 |
+
# "Timestamp": timestamp,
|
420 |
+
# "Activity": activity,
|
421 |
+
# "ID": user_id,
|
422 |
+
# "Positive": positive,
|
423 |
+
# "Mood": mood,
|
424 |
+
# }
|
425 |
+
|
426 |
+
# # Insert data into the Deta Base
|
427 |
+
# if st.button("Save Entry"):
|
428 |
+
# result = my_db.put(entry)
|
429 |
+
# st.success("Entry saved successfully:")
|
430 |
+
# st.write(result)
|
431 |
+
# import streamlit as st
|
432 |
+
# from datetime import datetime
|
433 |
+
# from deta import Deta
|
434 |
+
|
435 |
+
# # Load the environment variables
|
436 |
+
# DETA_KEY = "d0z8gryt9dj_HMVcfkbW7ZYYVeyz3xakbf48ZZGAxUtp"
|
437 |
+
|
438 |
+
# # Initialize with a project key
|
439 |
+
# deta = Deta(DETA_KEY)
|
440 |
+
|
441 |
+
# # Create Deta Base instance
|
442 |
+
# my_db = deta.Base("bright_psych_data")
|
443 |
+
|
444 |
+
# # Custom CSS
|
445 |
+
# custom_css = """
|
446 |
+
# <style>
|
447 |
+
# .main {
|
448 |
+
# background-color: #14839f;
|
449 |
+
# }
|
450 |
+
# .custom-header {
|
451 |
+
# color: #ffffff; /* Set your desired color for headers */
|
452 |
+
# font-size: 40px;
|
453 |
+
# font-weight: bold;
|
454 |
+
# margin-bottom: 10px;
|
455 |
+
# text-align: center;
|
456 |
+
# }
|
457 |
+
# .custom-subheader {
|
458 |
+
# color: #ffffff; /* Set your desired color for subheaders */
|
459 |
+
# font-size: 18px;
|
460 |
+
# margin-bottom: 5px;
|
461 |
+
# font-weight: bold;
|
462 |
+
# }
|
463 |
+
# </style>
|
464 |
+
# """
|
465 |
+
# st.markdown(custom_css, unsafe_allow_html=True)
|
466 |
+
|
467 |
+
# # Ask questions before entries
|
468 |
+
# st.markdown('<p class="custom-header">Daily Mood Tracker</p>', unsafe_allow_html=True)
|
469 |
+
|
470 |
+
# current_date = datetime.now().strftime("%Y-%m-%d")
|
471 |
+
# st.markdown(f'<p class="current-date">Date: {current_date}</p>', unsafe_allow_html=True)
|
472 |
+
|
473 |
+
# # Dynamic input fields for user data
|
474 |
+
# st.markdown('<p class="custom-subheader">Entry</p>', unsafe_allow_html=True)
|
475 |
+
# user_id = st.text_input("Enter an ID value: (User ID)", key="user_id_input", value="")
|
476 |
+
# Name = st.text_input("Enter your name:", key="name", value="")
|
477 |
+
# activity = st.text_input("What activity did you engage in today?", key="activity_input", value="")
|
478 |
+
# positive = st.text_input("Did you experience something positive today?", key="positive_input", value="")
|
479 |
+
# mood = st.text_input("Rate your mood on a scale of 1 to 10:", key="mood_input", value="")
|
480 |
+
|
481 |
+
# # Additional questions
|
482 |
+
# sleep_quality = st.slider("How well did you sleep last night? (Rate from 1 to 10)", 1, 10, 5, key="sleep_quality_input")
|
483 |
+
# stress_levels = st.slider("On a scale of 1 to 10, how would you rate your stress levels today?", 1, 10, 5, key="stress_levels_input")
|
484 |
+
# mindfulness = st.radio("Did you practice mindfulness or meditation today?", ["Yes", "No"], key="mindfulness_input")
|
485 |
+
# connection_to_others = st.slider("How connected do you feel to others? (Rate from 1 to 10)", 1, 10, 5, key="connection_to_others_input")
|
486 |
+
|
487 |
+
# # Add current date and time to the entry
|
488 |
+
# timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
489 |
+
# entry = {
|
490 |
+
# "Timestamp": timestamp,
|
491 |
+
# "Activity": activity,
|
492 |
+
# "ID": user_id,
|
493 |
+
# "Positive": positive,
|
494 |
+
# "Mood": mood,
|
495 |
+
# "SleepQuality": sleep_quality,
|
496 |
+
# "StressLevels": stress_levels,
|
497 |
+
# "Mindfulness": mindfulness,
|
498 |
+
# "ConnectionToOthers": connection_to_others,
|
499 |
+
# "Name": Name,
|
500 |
+
# }
|
501 |
+
|
502 |
+
# # Insert data into the Deta Base
|
503 |
+
# if st.button("Save Entry"):
|
504 |
+
# result = my_db.put(entry)
|
505 |
+
# st.success("Entry saved successfully:")
|
506 |
+
# st.write(result)
|
507 |
+
|
508 |
+
# import streamlit as st
|
509 |
+
# from datetime import datetime
|
510 |
+
# from deta import Deta
|
511 |
+
# import plotly.express as px
|
512 |
+
# import pandas as pd
|
513 |
+
|
514 |
+
# # Load the environment variables
|
515 |
+
# DETA_KEY = "d0z8gryt9dj_HMVcfkbW7ZYYVeyz3xakbf48ZZGAxUtp"
|
516 |
+
|
517 |
+
# # Initialize with a project key
|
518 |
+
# deta = Deta(DETA_KEY)
|
519 |
+
|
520 |
+
# # Create Deta Base instance
|
521 |
+
# my_db = deta.Base("bright_psych_data")
|
522 |
+
|
523 |
+
# # Custom CSS
|
524 |
+
# custom_css = """
|
525 |
+
# <style>
|
526 |
+
# .main {
|
527 |
+
# background-color: #14839f;
|
528 |
+
# }
|
529 |
+
# .custom-header {
|
530 |
+
# color: #ffffff; /* Set your desired color for headers */
|
531 |
+
# font-size: 40px;
|
532 |
+
# font-weight: bold;
|
533 |
+
# margin-bottom: 10px;
|
534 |
+
# text-align: center;
|
535 |
+
# }
|
536 |
+
# .custom-subheader {
|
537 |
+
# color: #ffffff; /* Set your desired color for subheaders */
|
538 |
+
# font-size: 18px;
|
539 |
+
# margin-bottom: 5px;
|
540 |
+
# font-weight: bold;
|
541 |
+
# }
|
542 |
+
# </style>
|
543 |
+
# """
|
544 |
+
# st.markdown(custom_css, unsafe_allow_html=True)
|
545 |
+
|
546 |
+
# # Ask questions before entries
|
547 |
+
# st.markdown('<p class="custom-header">Daily Mood Tracker</p>', unsafe_allow_html=True)
|
548 |
+
|
549 |
+
# current_date = datetime.now().strftime("%Y-%m-%d")
|
550 |
+
# st.markdown(f'<p class="current-date">Date: {current_date}</p>', unsafe_allow_html=True)
|
551 |
+
|
552 |
+
# # Dynamic input fields for user data
|
553 |
+
# st.markdown('<p class="custom-subheader">Entry</p>', unsafe_allow_html=True)
|
554 |
+
# user_id = st.text_input("Enter an ID value: (User ID)", key="user_id_input", value="")
|
555 |
+
# Name = st.text_input("Enter your name:", key="name", value="")
|
556 |
+
# activity = st.text_input("What activity did you engage in today?", key="activity_input", value="")
|
557 |
+
# positive = st.text_input("Did you experience something positive today?", key="positive_input", value="")
|
558 |
+
# mood = st.text_input("Rate your mood on a scale of 1 to 10:", key="mood_input", value="")
|
559 |
+
|
560 |
+
# # Additional questions
|
561 |
+
# sleep_quality = st.slider("How well did you sleep last night? (Rate from 1 to 10)", 1, 10, 5, key="sleep_quality_input")
|
562 |
+
# stress_levels = st.slider("On a scale of 1 to 10, how would you rate your stress levels today?", 1, 10, 5, key="stress_levels_input")
|
563 |
+
# mindfulness = st.radio("Did you practice mindfulness or meditation today?", ["Yes", "No"], key="mindfulness_input")
|
564 |
+
# connection_to_others = st.slider("How connected do you feel to others? (Rate from 1 to 10)", 1, 10, 5, key="connection_to_others_input")
|
565 |
+
|
566 |
+
# # Add current date and time to the entry
|
567 |
+
# timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
568 |
+
# entry = {
|
569 |
+
# "Timestamp": timestamp,
|
570 |
+
# "Activity": activity,
|
571 |
+
# "ID": user_id,
|
572 |
+
# "Positive": positive,
|
573 |
+
# "Mood": mood,
|
574 |
+
# "SleepQuality": sleep_quality,
|
575 |
+
# "StressLevels": stress_levels,
|
576 |
+
# "Mindfulness": mindfulness,
|
577 |
+
# "ConnectionToOthers": connection_to_others,
|
578 |
+
# "Name": Name,
|
579 |
+
# }
|
580 |
+
|
581 |
+
# # Insert data into the Deta Base
|
582 |
+
# if st.button("Save Entry"):
|
583 |
+
# result = my_db.put(entry)
|
584 |
+
# st.success("Entry saved successfully:")
|
585 |
+
# st.write(result)
|
586 |
+
|
587 |
+
# # Data Analysis and Bar Charts
|
588 |
+
# st.markdown('<p class="custom-header">Data Analysis</p>', unsafe_allow_html=True)
|
589 |
+
|
590 |
+
# # Retrieve all entries from the Deta Base
|
591 |
+
# entries = my_db.fetch().items
|
592 |
+
|
593 |
+
# # Group entries by user ID
|
594 |
+
# grouped_entries = {}
|
595 |
+
# for entry in entries:
|
596 |
+
# user_id = entry.get("ID")
|
597 |
+
# if user_id not in grouped_entries:
|
598 |
+
# grouped_entries[user_id] = []
|
599 |
+
# grouped_entries[user_id].append(entry)
|
600 |
+
|
601 |
+
# # Show bar charts for Mood, Connections to Others, Stress Levels, and Sleep Quality
|
602 |
+
# st.markdown('<p class="custom-subheader">Bar Charts for Each Person</p>', unsafe_allow_html=True)
|
603 |
+
|
604 |
+
# for user_id, user_entries in grouped_entries.items():
|
605 |
+
# st.markdown(f'<p class="custom-subheader">User ID: {user_id}</p>', unsafe_allow_html=True)
|
606 |
+
# df_user = pd.DataFrame(user_entries)
|
607 |
+
|
608 |
+
# # Bar chart for Mood
|
609 |
+
# fig_mood = px.bar(df_user, x="Timestamp", y="Mood", labels={'y': 'Mood'}, title=f'Mood for User ID: {user_id}')
|
610 |
+
# st.plotly_chart(fig_mood, use_container_width=True)
|
611 |
+
|
612 |
+
# # Bar chart for Connections to Others
|
613 |
+
# fig_connections = px.bar(df_user, x="Timestamp", y="ConnectionToOthers", labels={'y': 'Connections to Others'},
|
614 |
+
# title=f'Connections to Others for User ID: {user_id}')
|
615 |
+
# st.plotly_chart(fig_connections, use_container_width=True)
|
616 |
+
|
617 |
+
# # Bar chart for Stress Levels
|
618 |
+
# fig_stress = px.bar(df_user, x="Timestamp", y="StressLevels", labels={'y': 'Stress Levels'},
|
619 |
+
# title=f'Stress Levels for User ID: {user_id}')
|
620 |
+
# st.plotly_chart(fig_stress, use_container_width=True)
|
621 |
+
|
622 |
+
# # Bar chart for Sleep Quality
|
623 |
+
# fig_sleep_quality = px.bar(df_user, x="Timestamp", y="SleepQuality", labels={'y': 'Sleep Quality'},
|
624 |
+
# title=f'Sleep Quality for User ID: {user_id}')
|
625 |
+
# st.plotly_chart(fig_sleep_quality, use_container_width=True)
|
626 |
+
import streamlit as st
|
627 |
+
from datetime import datetime
|
628 |
+
from deta import Deta
|
629 |
+
import plotly.express as px
|
630 |
+
import pandas as pd
|
631 |
+
from streamlit.components.v1 import html
|
632 |
+
# Load the environment variables
|
633 |
+
DETA_KEY = "d0z8gryt9dj_HMVcfkbW7ZYYVeyz3xakbf48ZZGAxUtp"
|
634 |
+
|
635 |
+
# Initialize with a project key
|
636 |
+
deta = Deta(DETA_KEY)
|
637 |
+
|
638 |
+
# Create Deta Base instance
|
639 |
+
my_db = deta.Base("bright_psych_data")
|
640 |
+
|
641 |
+
# Custom CSS
|
642 |
+
custom_css = """
|
643 |
+
<style>
|
644 |
+
.main {
|
645 |
+
background-image: radial-gradient(circle, #81b7c9,#0986b0);
|
646 |
+
|
647 |
+
}
|
648 |
+
.custom-header {
|
649 |
+
color: #ffffff;
|
650 |
+
font-size: 40px;
|
651 |
+
font-weight: bold;
|
652 |
+
margin-bottom: 10px;
|
653 |
+
text-align: center;
|
654 |
+
}
|
655 |
+
.custom-subheader {
|
656 |
+
color: #ffffff;
|
657 |
+
font-size: 18px;
|
658 |
+
margin-bottom: 5px;
|
659 |
+
font-weight: bold;
|
660 |
+
}
|
661 |
+
</style>
|
662 |
+
"""
|
663 |
+
st.markdown(custom_css, unsafe_allow_html=True)
|
664 |
+
|
665 |
+
# Ask questions before entries
|
666 |
+
st.markdown('<p class="custom-header">Daily Mood Tracker</p>', unsafe_allow_html=True)
|
667 |
+
|
668 |
+
current_date = datetime.now().strftime("%Y-%m-%d")
|
669 |
+
st.markdown(f'<p class="current-date">Date: {current_date}</p>', unsafe_allow_html=True)
|
670 |
+
|
671 |
+
# Dynamic input fields for user data
|
672 |
+
st.markdown('<p class="custom-subheader">Entry</p>', unsafe_allow_html=True)
|
673 |
+
user_id = st.text_input("Enter an ID value: (User ID)", key="user_id_input", value="")
|
674 |
+
Name = st.text_input("Enter your name:", key="name", value="")
|
675 |
+
activity = st.text_input("What activity did you engage in today?", key="activity_input", value="")
|
676 |
+
positive = st.text_input("Did you experience something positive today?", key="positive_input", value="")
|
677 |
+
mood = st.text_input("Rate your mood on a scale of 1 to 10:", key="mood_input", value="")
|
678 |
+
|
679 |
+
# Additional questions
|
680 |
+
sleep_quality = st.slider("How well did you sleep last night? (Rate from 1 to 10)", 1, 10, 5, key="sleep_quality_input")
|
681 |
+
stress_levels = st.slider("On a scale of 1 to 10, how would you rate your stress levels today?", 1, 10, 5, key="stress_levels_input")
|
682 |
+
mindfulness = st.radio("Did you practice mindfulness or meditation today?", ["Yes", "No"], key="mindfulness_input")
|
683 |
+
connection_to_others = st.slider("How connected do you feel to others? (Rate from 1 to 10)", 1, 10, 5, key="connection_to_others_input")
|
684 |
+
|
685 |
+
# Add current date and time to the entry
|
686 |
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
687 |
+
entry = {
|
688 |
+
"Timestamp": timestamp,
|
689 |
+
"Activity": activity,
|
690 |
+
"ID": user_id,
|
691 |
+
"Positive": positive,
|
692 |
+
"Mood": mood,
|
693 |
+
"SleepQuality": sleep_quality,
|
694 |
+
"StressLevels": stress_levels,
|
695 |
+
"Mindfulness": mindfulness,
|
696 |
+
"ConnectionToOthers": connection_to_others,
|
697 |
+
"Name": Name,
|
698 |
+
}
|
699 |
+
|
700 |
+
# Insert data into the Deta Base
|
701 |
+
if st.button("Save Entry"):
|
702 |
+
result = my_db.put(entry)
|
703 |
+
st.success("Entry saved successfully:")
|
704 |
+
st.write(result)
|
705 |
+
|
706 |
+
# Data Analysis and Bar Charts
|
707 |
+
st.markdown('<p class="custom-header">Data Analysis</p>', unsafe_allow_html=True)
|
708 |
+
|
709 |
+
# Retrieve all entries from the Deta Base
|
710 |
+
entries = my_db.fetch().items
|
711 |
+
|
712 |
+
# Group entries by user ID
|
713 |
+
grouped_entries = {}
|
714 |
+
for entry in entries:
|
715 |
+
user_id = entry.get("ID")
|
716 |
+
if user_id not in grouped_entries:
|
717 |
+
grouped_entries[user_id] = []
|
718 |
+
grouped_entries[user_id].append(entry)
|
719 |
+
|
720 |
+
# Show bar charts for Mood, Connections to Others, Stress Levels, and Sleep Quality
|
721 |
+
st.markdown('<p class="custom-subheader">Bar Charts</p>', unsafe_allow_html=True)
|
722 |
+
|
723 |
+
# Dropdown to select a specific user ID
|
724 |
+
selected_user_id = st.selectbox("Select User ID", list(grouped_entries.keys()))
|
725 |
+
|
726 |
+
# Display bar charts for the selected user
|
727 |
+
st.markdown(f'<p class="custom-subheader">User ID: {selected_user_id}</p>', unsafe_allow_html=True)
|
728 |
+
df_selected_user = pd.DataFrame(grouped_entries[selected_user_id])
|
729 |
+
|
730 |
+
# Bar chart for Mood
|
731 |
+
fig_mood = px.bar(df_selected_user, x="Timestamp", y="Mood", labels={'y': 'Mood'}, title=f'Mood for User ID: {selected_user_id}')
|
732 |
+
st.plotly_chart(fig_mood, use_container_width=True)
|
733 |
+
|
734 |
+
# Bar chart for Connections to Others
|
735 |
+
fig_connections = px.bar(df_selected_user, x="Timestamp", y="ConnectionToOthers", labels={'y': 'Connections to Others'},
|
736 |
+
title=f'Connections to Others for User ID: {selected_user_id}')
|
737 |
+
st.plotly_chart(fig_connections, use_container_width=True)
|
738 |
+
|
739 |
+
# Bar chart for Stress Levels
|
740 |
+
fig_stress = px.bar(df_selected_user, x="Timestamp", y="StressLevels", labels={'y': 'Stress Levels'},
|
741 |
+
title=f'Stress Levels for User ID: {selected_user_id}')
|
742 |
+
st.plotly_chart(fig_stress, use_container_width=True)
|
743 |
+
|
744 |
+
# Bar chart for Sleep Quality
|
745 |
+
fig_sleep = px.bar(df_selected_user, x="Timestamp", y="SleepQuality", labels={'y': 'Sleep Quality'},
|
746 |
+
title=f'Sleep Quality for User ID: {selected_user_id}')
|
747 |
+
st.plotly_chart(fig_sleep, use_container_width=True)
|
748 |
+
from streamlit.components.v1 import html
|
749 |
+
|
750 |
+
# Define your javascript
|
751 |
+
my_js = """
|
752 |
+
alert("Please don't forget to enter you daily details!!!");
|
753 |
+
"""
|
754 |
+
|
755 |
+
# Wrapt the javascript as html code
|
756 |
+
my_html = f"<script>{my_js}</script>"
|
757 |
+
|
758 |
+
# Execute your app
|
759 |
+
|
760 |
+
html(my_html)
|
pages/Graphs.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
custom_styles = """
|
4 |
+
<style>
|
5 |
+
.main {
|
6 |
+
font-family: 'Arial', sans-serif;
|
7 |
+
color: #333;
|
8 |
+
line-height: 1.6;
|
9 |
+
background: #ffffff;
|
10 |
+
|
11 |
+
}
|
12 |
+
|
13 |
+
</style>
|
14 |
+
"""
|
15 |
+
|
16 |
+
# Render custom styles
|
17 |
+
st.markdown(custom_styles, unsafe_allow_html=True)
|
18 |
+
# Load your existing HTML file
|
19 |
+
with open("C:/Users/sharm/Downloads/ask-multiple-pdfs-main/ask-multiple-pdfs-main/output.html", "r", encoding="utf-8") as file:
|
20 |
+
html_content = file.read()
|
21 |
+
|
22 |
+
# st.markdown(html_content, unsafe_allow_html=True)
|
23 |
+
# Display the HTML content
|
24 |
+
st.components.v1.html(html_content, height=800,width=800, scrolling=True)
|
pages/Home.py
ADDED
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import streamlit as st
|
2 |
+
|
3 |
+
|
4 |
+
# st.set_page_config(
|
5 |
+
# page_title="Hello",
|
6 |
+
# page_icon="👋",
|
7 |
+
# )
|
8 |
+
|
9 |
+
# st.write("# Welcome to our website! 👋")
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
# st.markdown(
|
14 |
+
# """
|
15 |
+
# Welcome to [Your Website Name], your trusted companion on the journey to mental well-being and self-discovery. We understand that navigating the intricacies of mental health can be a challenging and personal experience. That's why we're here to offer a compassionate hand and a wealth of knowledge to guide you on your path to a healthier mind.""")
|
16 |
+
|
17 |
+
# st.subheader('Our Mission')
|
18 |
+
|
19 |
+
# st.markdown("""At [Your Website Name], our mission is to create a supportive online space where individuals can access valuable resources, expert insights, and connect with a community that shares their commitment to mental health. We believe that everyone deserves access to the tools and knowledge necessary for fostering emotional resilience and achieving a fulfilling life.""")
|
20 |
+
|
21 |
+
# st.subheader('What We Offer ?')
|
22 |
+
|
23 |
+
# st.markdown("""
|
24 |
+
# 1. Expert-Backed Information:
|
25 |
+
# Dive into a comprehensive collection of articles, blogs, and resources created by mental health professionals. Gain a deeper understanding of various mental health conditions, coping strategies, and wellness practices to empower yourself on your mental health journey.
|
26 |
+
|
27 |
+
# 2. Therapeutic Insights:
|
28 |
+
# Explore a variety of therapeutic approaches and gain insights into how they can support your well-being. Whether you're curious about cognitive-behavioral therapy, mindfulness, or other modalities, our platform provides valuable information to help you make informed decisions.
|
29 |
+
|
30 |
+
# 3. Community Support:
|
31 |
+
# Connect with a community of like-minded individuals who understand the challenges of navigating mental health. Share your experiences, provide support, and learn from others who are on similar paths. Our forums and discussion boards create a safe space for open dialogue and mutual understanding.
|
32 |
+
|
33 |
+
# 4. Online Therapy Resources:
|
34 |
+
# Access information on reputable online therapy services, allowing you to connect with licensed professionals from the comfort of your own space. Discover the convenience and effectiveness of virtual therapy as you work towards your mental health goals.
|
35 |
+
|
36 |
+
# """)
|
37 |
+
|
38 |
+
# st.subheader('Why choose us ?')
|
39 |
+
|
40 |
+
# st.markdown("""
|
41 |
+
|
42 |
+
# - Compassionate Approach:
|
43 |
+
# We approach mental health with empathy, understanding, and a commitment to reducing the stigma surrounding it. Our content is designed to uplift, inspire, and provide the support you need.
|
44 |
+
|
45 |
+
# - Holistic Wellness:
|
46 |
+
# We believe in a holistic approach to mental health that encompasses emotional, physical, and social well-being. Our resources cover a wide range of topics to support you on your journey to a balanced and fulfilling life.
|
47 |
+
|
48 |
+
# - Trustworthy Information:
|
49 |
+
# Rest assured that the information provided on our platform is curated by mental health professionals and experts. We prioritize accuracy and reliability to ensure you receive the most trustworthy guidance.
|
50 |
+
# """)
|
51 |
+
|
52 |
+
# import streamlit as st
|
53 |
+
|
54 |
+
# # Set page configuration
|
55 |
+
# st.set_page_config(
|
56 |
+
# page_title="Hello",
|
57 |
+
# page_icon="seedling:",
|
58 |
+
# )
|
59 |
+
|
60 |
+
# # Define custom CSS styles
|
61 |
+
# custom_styles = """
|
62 |
+
# <style>
|
63 |
+
# .main {
|
64 |
+
# font-family: 'Arial', sans-serif;
|
65 |
+
# background-color: #f5f5f5;
|
66 |
+
# color: #333;
|
67 |
+
# line-height: 1.6;
|
68 |
+
# }
|
69 |
+
|
70 |
+
# h1, h2, h3, h4, h5, h6 {
|
71 |
+
# color: #fa0f79;
|
72 |
+
# }
|
73 |
+
|
74 |
+
# .container {
|
75 |
+
# max-width: 800px;
|
76 |
+
# margin: 0 auto;
|
77 |
+
# }
|
78 |
+
|
79 |
+
# .welcome-section {
|
80 |
+
# background-color: #ffffff;
|
81 |
+
# padding: 20px;
|
82 |
+
# border-radius: 10px;
|
83 |
+
# box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
84 |
+
# margin-bottom: 20px;
|
85 |
+
# }
|
86 |
+
|
87 |
+
# .mission-section, .offer-section, .choose-us-section {
|
88 |
+
# background-color: #f8f8f8;
|
89 |
+
# padding: 20px;
|
90 |
+
# border-radius: 10px;
|
91 |
+
# box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
92 |
+
# margin-bottom: 20px;
|
93 |
+
# }
|
94 |
+
# </style>
|
95 |
+
# """
|
96 |
+
|
97 |
+
# # Render custom styles
|
98 |
+
# st.markdown(custom_styles, unsafe_allow_html=True)
|
99 |
+
|
100 |
+
# # Content
|
101 |
+
# st.write("# Welcome to our website! :seedling:")
|
102 |
+
|
103 |
+
# st.markdown(
|
104 |
+
# """
|
105 |
+
# Welcome to [Your Website Name], your trusted companion on the journey to mental well-being and self-discovery. We understand that navigating the intricacies of mental health can be a challenging and personal experience. That's why we're here to offer a compassionate hand and a wealth of knowledge to guide you on your path to a healthier mind."""
|
106 |
+
# )
|
107 |
+
|
108 |
+
# st.subheader('Our Mission')
|
109 |
+
|
110 |
+
# st.markdown("""At [Your Website Name], our mission is to create a supportive online space where individuals can access valuable resources, expert insights, and connect with a community that shares their commitment to mental health. We believe that everyone deserves access to the tools and knowledge necessary for fostering emotional resilience and achieving a fulfilling life.""")
|
111 |
+
|
112 |
+
# st.subheader('What We Offer ?')
|
113 |
+
|
114 |
+
# st.markdown("""
|
115 |
+
# 1. Expert-Backed Information:
|
116 |
+
# Dive into a comprehensive collection of articles, blogs, and resources created by mental health professionals. Gain a deeper understanding of various mental health conditions, coping strategies, and wellness practices to empower yourself on your mental health journey.
|
117 |
+
|
118 |
+
# 2. Therapeutic Insights:
|
119 |
+
# Explore a variety of therapeutic approaches and gain insights into how they can support your well-being. Whether you're curious about cognitive-behavioral therapy, mindfulness, or other modalities, our platform provides valuable information to help you make informed decisions.
|
120 |
+
|
121 |
+
# 3. Community Support:
|
122 |
+
# Connect with a community of like-minded individuals who understand the challenges of navigating mental health. Share your experiences, provide support, and learn from others who are on similar paths. Our forums and discussion boards create a safe space for open dialogue and mutual understanding.
|
123 |
+
|
124 |
+
# 4. Online Therapy Resources:
|
125 |
+
# Access information on reputable online therapy services, allowing you to connect with licensed professionals from the comfort of your own space. Discover the convenience and effectiveness of virtual therapy as you work towards your mental health goals.
|
126 |
+
|
127 |
+
# """)
|
128 |
+
|
129 |
+
# st.subheader('Why choose us ?')
|
130 |
+
|
131 |
+
# st.markdown("""
|
132 |
+
|
133 |
+
# - Compassionate Approach:
|
134 |
+
# We approach mental health with empathy, understanding, and a commitment to reducing the stigma surrounding it. Our content is designed to uplift, inspire, and provide the support you need.
|
135 |
+
|
136 |
+
# - Holistic Wellness:
|
137 |
+
# We believe in a holistic approach to mental health that encompasses emotional, physical, and social well-being. Our resources cover a wide range of topics to support you on your journey to a balanced and fulfilling life.
|
138 |
+
|
139 |
+
# - Trustworthy Information:
|
140 |
+
# Rest assured that the information provided on our platform is curated by mental health professionals and experts. We prioritize accuracy and reliability to ensure you receive the most trustworthy guidance.
|
141 |
+
# """)
|
142 |
+
|
143 |
+
import streamlit as st
|
144 |
+
from datetime import datetime
|
145 |
+
import pandas as pd
|
146 |
+
|
147 |
+
|
148 |
+
# Set page configuration
|
149 |
+
st.set_page_config(
|
150 |
+
page_title="BrightPsych",
|
151 |
+
page_icon="seedling",
|
152 |
+
)
|
153 |
+
|
154 |
+
# Define custom CSS styles
|
155 |
+
custom_styles = """
|
156 |
+
<style>
|
157 |
+
.main {
|
158 |
+
font-family: 'Arial', sans-serif;
|
159 |
+
color: #333;
|
160 |
+
line-height: 1.6;
|
161 |
+
background: radial-gradient(circle, hsl(40, 100%, 90%) 0%, hsl(40, 100%, 80%) 100%);
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
h1, h2, h3, h4, h5, h6 {
|
166 |
+
color: #fa0f79;
|
167 |
+
}
|
168 |
+
|
169 |
+
.container {
|
170 |
+
max-width: 800px;
|
171 |
+
margin: 0 auto;
|
172 |
+
}
|
173 |
+
|
174 |
+
.section {
|
175 |
+
background-color: #ffffff;
|
176 |
+
padding: 20px;
|
177 |
+
border-radius: 10px;
|
178 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
179 |
+
margin-bottom: 20px;
|
180 |
+
}
|
181 |
+
|
182 |
+
</style>
|
183 |
+
"""
|
184 |
+
|
185 |
+
# Render custom styles
|
186 |
+
st.markdown(custom_styles, unsafe_allow_html=True)
|
187 |
+
|
188 |
+
# Section: Welcome
|
189 |
+
st.markdown("# Welcome to BrightPsych! :seedling:")
|
190 |
+
|
191 |
+
st.markdown(
|
192 |
+
"""
|
193 |
+
Welcome to BrightPsych, your trusted destination for mental well-being. Our platform offers a range of services to support you on your journey to emotional health and self-discovery. Explore the features below and embark on a path towards a brighter mind.
|
194 |
+
"""
|
195 |
+
)
|
196 |
+
|
197 |
+
# Section: Empathetic Chat Bot
|
198 |
+
st.markdown("## Empathetic Chat Bot")
|
199 |
+
st.markdown(
|
200 |
+
"""
|
201 |
+
Connect with our empathetic chat bot for a supportive conversation. Whether you need someone to talk to or seek guidance, our chat bot is here for you.
|
202 |
+
"""
|
203 |
+
)
|
204 |
+
# Your chat bot implementation goes here
|
205 |
+
|
206 |
+
# Section: CBT Analysis
|
207 |
+
st.markdown("## CBT Analysis of Disorders")
|
208 |
+
st.markdown(
|
209 |
+
"""
|
210 |
+
Explore Cognitive Behavioral Therapy (CBT) analyses of common disorders, including PTSD, ADHD, and BPD. Gain insights into effective therapeutic approaches.
|
211 |
+
"""
|
212 |
+
)
|
213 |
+
# Your CBT analysis implementation goes here
|
214 |
+
|
215 |
+
# Section: Daily Mood Tracking
|
216 |
+
st.markdown("## Daily Mood Tracking")
|
217 |
+
st.markdown(
|
218 |
+
"""
|
219 |
+
Track your daily mood and well-being by answering a few questions. Understand patterns, set goals, and prioritize your mental health.
|
220 |
+
"""
|
221 |
+
)
|
222 |
+
# Your daily mood tracking implementation goes here
|
223 |
+
|
224 |
+
# Section: Data Analysis
|
225 |
+
st.markdown("## Data Analysis of 'Student_Mental_Health' Dataset")
|
226 |
+
st.markdown(
|
227 |
+
"""
|
228 |
+
Dive into the analysis of a dataset focused on student mental health. Discover trends, correlations, and insights to promote a supportive environment.
|
229 |
+
"""
|
230 |
+
)
|
231 |
+
# Your data analysis implementation goes here
|
232 |
+
|
233 |
+
# Section: Mindfulness Session
|
234 |
+
st.markdown("## Mindfulness Session")
|
235 |
+
st.markdown(
|
236 |
+
"""
|
237 |
+
Join our mindfulness session for guided meditation and relaxation. Nurture a peaceful mind and enhance your overall well-being.
|
238 |
+
"""
|
239 |
+
)
|
240 |
+
# Your mindfulness session implementation goes here
|
241 |
+
|
242 |
+
# Footer Section
|
243 |
+
st.markdown("<footer class='custom-footer'>", unsafe_allow_html=True)
|
244 |
+
# Footer Section
|
245 |
+
st.markdown("---")
|
246 |
+
st.write("© 2024 BrightPsych. All rights reserved.")
|
247 |
+
st.write("Contact us at: [info@brightpsych.com](mailto:info@brightpsych.com)")
|
248 |
+
|
249 |
+
st.markdown("</footer>", unsafe_allow_html=True)
|
pages/Mindfulness.py
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from pydub import AudioSegment
|
3 |
+
import tempfile
|
4 |
+
|
5 |
+
def main():
|
6 |
+
st.title("Mindfulness Steps")
|
7 |
+
|
8 |
+
# Apply custom CSS styling
|
9 |
+
st.markdown(
|
10 |
+
"""
|
11 |
+
<style>
|
12 |
+
.title {
|
13 |
+
color: #034525;
|
14 |
+
font-size: 40px;
|
15 |
+
text-align: center;
|
16 |
+
margin-bottom: 20px;
|
17 |
+
font-weight: bold;
|
18 |
+
}
|
19 |
+
h1{
|
20 |
+
color:#034525;
|
21 |
+
}
|
22 |
+
.text {
|
23 |
+
font-size: 16px;
|
24 |
+
line-height: 1.5;
|
25 |
+
color: #034525;
|
26 |
+
margin-bottom: 20px; /* Adjust the value as needed */
|
27 |
+
text-align: justify;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
.button {
|
32 |
+
margin-top: 20px;
|
33 |
+
padding: 10px 20px;
|
34 |
+
font-size: 18px;
|
35 |
+
cursor: pointer;
|
36 |
+
}
|
37 |
+
.main{
|
38 |
+
background: radial-gradient(circle, #aae3c8 0%, #a1e3c8 50%, #8dd6c8 100%);
|
39 |
+
|
40 |
+
}
|
41 |
+
</style>
|
42 |
+
""",
|
43 |
+
unsafe_allow_html=True
|
44 |
+
)
|
45 |
+
|
46 |
+
meditation_steps = [
|
47 |
+
"1)Find Your Quiet Spot: Find a cozy and quiet space where you won't be disturbed. It could be a corner in your room, a comfortable chair, or even a quiet park bench.",
|
48 |
+
"2)Set a Time Limit: Start small. Decide on a reasonable time for your meditation session. Five minutes is perfect for beginners. You can always increase it as you get more comfortable.",
|
49 |
+
"3)Get Comfortable: Sit comfortably on a cushion or chair. Make sure your back is straight, and your hands are resting on your lap or knees. Close your eyes gently or keep a soft gaze.",
|
50 |
+
"4)Focus on Your Breath: Take a moment to notice your breath. Feel the sensation as you breathe in and out. It could be the air passing through your nostrils, the rise and fall of your chest, or the movement of your abdomen.",
|
51 |
+
"5)Be Present: As you focus on your breath, your mind might wander. That's okay! When you notice it happening, gently guide your attention back to your breath. Be in the moment.",
|
52 |
+
"6)No Judgments: Remember, there's no right or wrong here. If your mind wanders, don't be hard on yourself. Just acknowledge it and bring your focus back to your breath. It's a practice, not a perfect.",
|
53 |
+
"7)Body Scan: If you want, scan your body from toes to head. Notice any sensations or tension, and let them go as you breathe.",
|
54 |
+
"8)Loving-Kindness: Spread some love. In your mind, say phrases like May I/you be happy, may I/you be healthy, may I/you be safe, may I/you be at ease.",
|
55 |
+
"9)Gradual End: As your session time ends, slowly bring your awareness back. Open your eyes, take a deep breath, and notice how you feel. Carry this sense of presence into the rest of your day.",
|
56 |
+
]
|
57 |
+
|
58 |
+
# Display meditation steps with custom styling
|
59 |
+
st.markdown('<p class="text">' + '<br>'.join(meditation_steps) + '</p>', unsafe_allow_html=True)
|
60 |
+
|
61 |
+
# Voice selection
|
62 |
+
voice_options = ["Male Voice", "Female Voice"]
|
63 |
+
selected_voice = st.radio("Select Voice:", voice_options)
|
64 |
+
|
65 |
+
# Play audio button
|
66 |
+
if st.button("Play Audio"):
|
67 |
+
# Load audio file based on the selected voice
|
68 |
+
if selected_voice == "Male Voice":
|
69 |
+
audio_path = "C:/Users/sharm/Downloads/ask-multiple-pdfs-main/ask-multiple-pdfs-main/meditation_steps_male.wav"
|
70 |
+
else:
|
71 |
+
audio_path = "C:/Users/sharm/Downloads/ask-multiple-pdfs-main/ask-multiple-pdfs-main/meditation_steps_female.wav"
|
72 |
+
|
73 |
+
audio = AudioSegment.from_wav(audio_path)
|
74 |
+
|
75 |
+
# Save audio to a temporary file
|
76 |
+
temp_audio_path = tempfile.NamedTemporaryFile(delete=False, suffix=".wav").name
|
77 |
+
audio.export(temp_audio_path, format="wav")
|
78 |
+
|
79 |
+
# Play the saved audio file
|
80 |
+
st.audio(temp_audio_path, format="audio/wav", start_time=0, sample_rate=44100)
|
81 |
+
|
82 |
+
if __name__ == "__main__":
|
83 |
+
main()
|
84 |
+
|
85 |
+
# from streamlit.components.v1 import html
|
86 |
+
|
87 |
+
# Define your javascript
|
88 |
+
# my_js = """
|
89 |
+
# alert("Please don't forget to enter you daily details!!!");
|
90 |
+
# """
|
91 |
+
|
92 |
+
# # Wrapt the javascript as html code
|
93 |
+
# my_html = f"<script>{my_js}</script>"
|
94 |
+
|
95 |
+
# # Execute your app
|
96 |
+
|
97 |
+
# html(my_html)
|