Spaces:
Sleeping
Sleeping
File size: 26,156 Bytes
066701f a76c6ff 066701f a76c6ff 066701f b7addcc 066701f b7addcc 066701f b7addcc 066701f b7addcc 066701f a76c6ff 066701f a76c6ff 066701f a76c6ff 066701f a76c6ff 066701f |
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
import streamlit as st
import pandas as pd
import numpy as np
import time
import random
import os
import hashlib
import json
from datetime import datetime
def load_famous_quotes():
famous_quotes = [
{"Number": 1, "Quote Topic": "Imagination", "Quote": "The true sign of intelligence is not knowledge but imagination. β Albert Einstein"},
{"Number": 2, "Quote Topic": "Perseverance", "Quote": "I have not failed. I've just found 10,000 ways that won't work. β Thomas Edison"},
{"Number": 3, "Quote Topic": "Innovation", "Quote": "Innovation distinguishes between a leader and a follower. β Steve Jobs"},
{"Number": 4, "Quote Topic": "Research", "Quote": "Research is what I'm doing when I don't know what I'm doing. β Wernher von Braun"},
{"Number": 5, "Quote Topic": "Possibility", "Quote": "The only way to discover the limits of the possible is to go beyond them into the impossible. β Arthur C. Clarke"},
{"Number": 6, "Quote Topic": "Success", "Quote": "Success is a science; if you have the conditions, you get the result. β Oscar Wilde"},
{"Number": 7, "Quote Topic": "Expertise", "Quote": "An expert is a person who has made all the mistakes that can be made in a very narrow field. β Niels Bohr"},
{"Number": 8, "Quote Topic": "Curiosity", "Quote": "The important thing is to not stop questioning. Curiosity has its own reason for existing. β Albert Einstein"},
{"Number": 9, "Quote Topic": "Future", "Quote": "The best way to predict the future is to invent it. β Alan Kay"},
{"Number": 10, "Quote Topic": "Progress", "Quote": "If I have seen further it is by standing on the shoulders of Giants. β Isaac Newton"},
{"Number": 11, "Quote Topic": "Logic and Imagination", "Quote": "Logic will get you from A to B. Imagination will take you everywhere. β Albert Einstein"},
{"Number": 12, "Quote Topic": "Imagination", "Quote": "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world. β Albert Einstein"},
{"Number": 13, "Quote Topic": "Science", "Quote": "Science is a way of thinking much more than it is a body of knowledge. β Carl Sagan"},
{"Number": 14, "Quote Topic": "Problem Solving", "Quote": "We cannot solve our problems with the same thinking we used when we created them. β Albert Einstein"},
{"Number": 15, "Quote Topic": "Experimentation", "Quote": "The true method of knowledge is experiment. β William Blake"},
{"Number": 16, "Quote Topic": "Questions", "Quote": "The scientist is not a person who gives the right answers, he's one who asks the right questions. β Claude Levi-Strauss"},
{"Number": 17, "Quote Topic": "Possibility", "Quote": "It's kind of fun to do the impossible. β Walt Disney"},
{"Number": 18, "Quote Topic": "Technology", "Quote": "Any sufficiently advanced technology is indistinguishable from magic. β Arthur C. Clarke"},
{"Number": 19, "Quote Topic": "Creativity", "Quote": "Creativity is intelligence having fun. β Albert Einstein"},
{"Number": 20, "Quote Topic": "Invention", "Quote": "To invent, you need a good imagination and a pile of junk. β Thomas Edison"}
]
return pd.DataFrame(famous_quotes)
# Predefined custom quotes
custom_quotes = [
{"Number": 1, "Quote Topic": "Stages of Life π±", "Quote": "Every age unfolds a new lesson. Life's chapters evolve, each teaching us anew."},
{"Number": 2, "Quote Topic": "Stages of Life π±", "Quote": "From infancy to twilight, our journey is painted in growth. Every stage shines with its own wisdom."},
{"Number": 3, "Quote Topic": "Identity π", "Quote": "We piece together our identity with experiences. In the vast cosmos, our ever-changing signature is our identity."},
{"Number": 4, "Quote Topic": "Identity π", "Quote": "We aren't born with a defined self. Our identity is an art, crafted through introspection and encounters."},
{"Number": 5, "Quote Topic": "Enlightenment π‘", "Quote": "Every step towards enlightenment is a dive within. It's an ongoing journey of self and universe."},
{"Number": 6, "Quote Topic": "Enlightenment π‘", "Quote": "True insight isn't just about knowledge. It's the harmony of mind, heart, and soul."},
{"Number": 7, "Quote Topic": "Adaptive Resonance Theory π§ ", "Quote": "Our cognition is like a river, ever-flowing and adapting. Every experience shapes its course, forming new resonances."},
{"Number": 8, "Quote Topic": "Adaptive Resonance Theory π§ ", "Quote": "The brain's capacity to learn is profound. It finds its rhythm in adaptive resonances."},
{"Number": 9, "Quote Topic": "Panpsychism π", "Quote": "The universe might hum with consciousness in every atom. Every speck could be part of this grand song."},
{"Number": 10, "Quote Topic": "Panpsychism π", "Quote": "What if consciousness isn't exclusive to us? The universe's shared melody might be sung by all."},
{"Number": 11, "Quote Topic": "How to Think π€", "Quote": "Thinking isn't about arriving, it's about exploring. Dive deep, question, and embrace the universe within."},
{"Number": 12, "Quote Topic": "How to Think π€", "Quote": "To think profoundly is to touch the cosmos. It's about connecting with the vastness and intricacies it holds."},
{"Number": 13, "Quote Topic": "Plants Communication πΏ", "Quote": "In every leaf and root, plants tell tales of life. Their silent growth is a language we're just beginning to decipher."},
{"Number": 14, "Quote Topic": "Plants Communication πΏ", "Quote": "Nature's every rustle is a whispered secret. It's a testament to the intricate web of communication."},
{"Number": 15, "Quote Topic": "Fame π", "Quote": "True impact outlives fleeting fame. What endures is the legacy we craft, not the applause we receive."},
{"Number": 16, "Quote Topic": "Fame π", "Quote": "Fame might shine bright, but it's transient. Genuine influence is the silent footprint we leave in time."},
{"Number": 17, "Quote Topic": "Happiness π", "Quote": "True happiness is an inner light that shines brightest in shared moments."},
{"Number": 18, "Quote Topic": "Happiness π", "Quote": "Life's riches aren't material but the joyous moments and heartfelt memories we gather."},
{"Number": 19, "Quote Topic": "Exercise π", "Quote": "Exercise is the symphony of the body, resonating with health and vitality."},
{"Number": 20, "Quote Topic": "Exercise π", "Quote": "In movement, we find balance, strength, and a celebration of life's potential."},
{"Number": 21, "Quote Topic": "Good Habits π", "Quote": "Good habits are the bricks that build the mansion of success."},
{"Number": 22, "Quote Topic": "Good Habits π", "Quote": "Consistency in habits crafts our destiny, one action at a time."},
{"Number": 23, "Quote Topic": "Discipline π°οΈ", "Quote": "Discipline is the bridge between dreams and their realization."},
{"Number": 24, "Quote Topic": "Discipline π°οΈ", "Quote": "Through discipline, chaos transforms into order, and aspirations into achievements."},
{"Number": 25, "Quote Topic": "Stamina π", "Quote": "Stamina isn't just enduring but thriving amidst challenges."},
{"Number": 26, "Quote Topic": "Stamina π", "Quote": "It's stamina that turns obstacles into stepping stones, fueling our journey forward."},
{"Number": 27, "Quote Topic": "Artificial General Intelligence π€―", "Quote": "AGI is not just about mimicking humans but understanding the core of intelligence itself."},
{"Number": 28, "Quote Topic": "Artificial General Intelligence π€―", "Quote": "The pursuit of AGI is a testament to humanity's quest to transcend its own boundaries."},
{"Number": 29, "Quote Topic": "AI Pipelines π οΈ", "Quote": "AI pipelines are the arteries of intelligent systems, directing the flow of knowledge."},
{"Number": 30, "Quote Topic": "AI Pipelines π οΈ", "Quote": "In well-crafted pipelines, AI finds its rhythm, efficiency, and transformative power."},
{"Number": 31, "Quote Topic": "Genius π", "Quote": "Genius isn't just raw talent; it's the alchemy of persistence, passion, and perspective."},
{"Number": 32, "Quote Topic": "Genius π", "Quote": "Every spark of genius has been nurtured by curiosity and an insatiable thirst for knowledge."},
{"Number": 33, "Quote Topic": "Our Brains π§ ", "Quote": "Our brain is the universe's masterpiece, a nexus of thoughts, dreams, and memories."},
{"Number": 34, "Quote Topic": "Our Brains π§ ", "Quote": "In every neuron, our brain holds the potential of countless possibilities and imaginations."},
{"Number": 35, "Quote Topic": "Our Brains π§ ", "Quote": "The intricacies of our brain reflect the cosmos: vast, complex, and beautifully mysterious."},
{"Number": 36, "Quote Topic": "Our Brains π§ ", "Quote": "Understanding our brain is the key to unlocking the enigmas of consciousness, behavior, and potential."},
{"Number": 37, "Quote Topic": "Mindfulness πΌ", "Quote": "Mindfulness is the anchor that grounds us in the present, amidst life's tumultuous seas."},
{"Number": 38, "Quote Topic": "Mindfulness πΌ", "Quote": "In the act of being mindful, we embrace life's symphony, note by note, moment by moment."},
{"Number": 39, "Quote Topic": "Resilience πͺ", "Quote": "Resilience is the art of bouncing back, turning wounds into wisdom and setbacks into comebacks."},
{"Number": 40, "Quote Topic": "Resilience πͺ", "Quote": "Life will test us, but with resilience, we rise, stronger and more enlightened."},
{"Number": 41, "Quote Topic": "Innovation π‘", "Quote": "Innovation is the heartbeat of progress, pushing boundaries and redefining possibilities."},
{"Number": 42, "Quote Topic": "Innovation π‘", "Quote": "Every breakthrough, every invention, is a testament to humanity's relentless spirit of innovation."},
{"Number": 43, "Quote Topic": "Empathy β€οΈ", "Quote": "Empathy is the bridge between souls, transcending words and touching hearts."},
{"Number": 44, "Quote Topic": "Empathy β€οΈ", "Quote": "Through empathy, we see the world through another's eyes, fostering understanding and unity."},
{"Number": 45, "Quote Topic": "Happiness π", "Quote": "True happiness is an inner light that shines brightest in shared moments."},
{"Number": 46, "Quote Topic": "Happiness π", "Quote": "Life's riches aren't material but the joyous moments and heartfelt memories we gather."},
{"Number": 47, "Quote Topic": "Exercise π", "Quote": "Exercise is the symphony of the body, resonating with health and vitality."},
{"Number": 48, "Quote Topic": "Exercise π", "Quote": "In movement, we find balance, strength, and a celebration of life's potential."},
{"Number": 49, "Quote Topic": "Good Habits π", "Quote": "Good habits are the bricks that build the mansion of success."},
{"Number": 50, "Quote Topic": "Good Habits π", "Quote": "Consistency in habits crafts our destiny, one action at a time."},
{"Number": 51, "Quote Topic": "Discipline π°οΈ", "Quote": "Discipline is the bridge between dreams and their realization."},
{"Number": 52, "Quote Topic": "Discipline π°οΈ", "Quote": "Through discipline, chaos transforms into order, and aspirations into achievements."},
{"Number": 53, "Quote Topic": "Stamina π", "Quote": "Stamina isn't just enduring but thriving amidst challenges."},
{"Number": 54, "Quote Topic": "Stamina π", "Quote": "It's stamina that turns obstacles into stepping stones, fueling our journey forward."},
{"Number": 55, "Quote Topic": "Artificial General Intelligence π€―", "Quote": "AGI is not just about mimicking humans but understanding the core of intelligence itself."},
{"Number": 56, "Quote Topic": "Artificial General Intelligence π€―", "Quote": "The pursuit of AGI is a testament to humanity's quest to transcend its own boundaries."},
{"Number": 57, "Quote Topic": "AI Pipelines π οΈ", "Quote": "AI pipelines are the arteries of intelligent systems, directing the flow of knowledge."},
{"Number": 58, "Quote Topic": "AI Pipelines π οΈ", "Quote": "In well-crafted pipelines, AI finds its rhythm, efficiency, and transformative power."},
{"Number": 59, "Quote Topic": "Genius π", "Quote": "Genius isn't just raw talent; it's the alchemy of persistence, passion, and perspective."},
{"Number": 60, "Quote Topic": "Genius π", "Quote": "Every spark of genius has been nurtured by curiosity and an insatiable thirst for knowledge."},
{"Number": 61, "Quote Topic": "Our Brains π§ ", "Quote": "Our brain is the universe's masterpiece, a nexus of thoughts, dreams, and memories."},
{"Number": 62, "Quote Topic": "Our Brains π§ ", "Quote": "In every neuron, our brain holds the potential of countless possibilities and imaginations."},
{"Number": 63, "Quote Topic": "Our Brains π§ ", "Quote": "The intricacies of our brain reflect the cosmos: vast, complex, and beautifully mysterious."},
{"Number": 64, "Quote Topic": "Our Brains π§ ", "Quote": "Understanding our brain is the key to unlocking the enigmas of consciousness, behavior, and potential."},
{"Number": 65, "Quote Topic": "Mindfulness πΌ", "Quote": "Mindfulness is the anchor that grounds us in the present, amidst life's tumultuous seas."},
{"Number": 66, "Quote Topic": "Mindfulness πΌ", "Quote": "In the act of being mindful, we embrace life's symphony, note by note, moment by moment."},
{"Number": 67, "Quote Topic": "Resilience πͺ", "Quote": "Resilience is the art of bouncing back, turning wounds into wisdom and setbacks into comebacks."},
{"Number": 68, "Quote Topic": "Resilience πͺ", "Quote": "Life will test us, but with resilience, we rise, stronger and more enlightened."},
{"Number": 69, "Quote Topic": "Innovation π‘", "Quote": "Innovation is the heartbeat of progress, pushing boundaries and redefining possibilities."},
{"Number": 70, "Quote Topic": "Innovation π‘", "Quote": "Every breakthrough, every invention, is a testament to humanity's relentless spirit of innovation."},
{"Number": 71, "Quote Topic": "Empathy β€οΈ", "Quote": "Empathy is the bridge between souls, transcending words and touching hearts."},
{"Number": 72, "Quote Topic": "Empathy β€οΈ", "Quote": "Through empathy, we see the world through another's eyes, fostering understanding and unity."},
{"Number": 73, "Quote Topic": "Inspiration π", "Quote": "Inspiration is the spark that ignites the soul, propelling us to chase our dreams."},
{"Number": 74, "Quote Topic": "Inspiration π", "Quote": "Every moment of inspiration is a call to action, pushing us beyond our boundaries."},
{"Number": 75, "Quote Topic": "Learning π", "Quote": "Learning is the gateway to growth, opening doors to endless possibilities."},
{"Number": 76, "Quote Topic": "Learning π", "Quote": "Every lesson learned is a step towards enlightenment, broadening our horizons."},
{"Number": 77, "Quote Topic": "Collaboration π€", "Quote": "In collaboration, we find strength. Together, we achieve more than we could alone."},
{"Number": 78, "Quote Topic": "Collaboration π€", "Quote": "Unity in purpose paves the way for monumental achievements, showcasing the power of collective effort."},
{"Number": 79, "Quote Topic": "Dreams π", "Quote": "Dreams are the architects of our future. They sketch the blueprint of our aspirations."},
{"Number": 80, "Quote Topic": "Dreams π", "Quote": "In dreams, we find hope, and with hope, we transform the fabric of reality."},
{"Number": 81, "Quote Topic": "Courage π¦", "Quote": "Courage is the fire that lights our path, even in the face of overwhelming odds."},
{"Number": 82, "Quote Topic": "Courage π¦", "Quote": "With courage in our hearts, we defy limitations and embrace the vastness of potential."},
{"Number": 83, "Quote Topic": "Change π", "Quote": "Change is life's only constant. It shapes, molds, and propels us forward."},
{"Number": 84, "Quote Topic": "Change π", "Quote": "Embracing change is embracing growth, an acknowledgment of life's ever-evolving nature."},
{"Number": 85, "Quote Topic": "Adventure π", "Quote": "Life is an adventure, filled with twists, turns, and unexpected discoveries."},
{"Number": 86, "Quote Topic": "Adventure π", "Quote": "Every adventure, big or small, adds a chapter to our story, enriching our experience."},
{"Number": 87, "Quote Topic": "Creativity π¨", "Quote": "Creativity is the dance of the soul, expressing itself in countless forms."},
{"Number": 88, "Quote Topic": "Creativity π¨", "Quote": "Through creativity, we paint the world in vibrant colors, showcasing our unique perspectives."},
{"Number": 89, "Quote Topic": "Passion β€οΈ", "Quote": "Passion is the fuel for our journey, driving us to chase after our dreams."},
{"Number": 90, "Quote Topic": "Passion β€οΈ", "Quote": "With passion, every task becomes a labor of love, and every challenge, a thrilling endeavor."},
{"Number": 91, "Quote Topic": "Hope π", "Quote": "Hope is the beacon that guides us through stormy nights, reminding us of the dawn that awaits."},
{"Number": 92, "Quote Topic": "Hope π", "Quote": "In hope, we find solace, and in its embrace, we find the strength to persevere."},
{"Number": 93, "Quote Topic": "Intuition π§", "Quote": "Intuition is the silent whisper of the soul, guiding us with its subtle wisdom."},
{"Number": 94, "Quote Topic": "Intuition π§", "Quote": "By tuning into our intuition, we align with our inner compass, navigating life with clarity."},
{"Number": 95, "Quote Topic": "Joy π", "Quote": "Joy is the melody of the heart, a song of gratitude and love."},
{"Number": 96, "Quote Topic": "Joy π", "Quote": "In moments of joy, we connect with the essence of life, celebrating its beauty."},
{"Number": 97, "Quote Topic": "Wisdom π¦", "Quote": "Wisdom is the culmination of experience, a treasure trove of insights and reflections."},
{"Number": 98, "Quote Topic": "Wisdom π¦", "Quote": "With wisdom, we navigate life's complexities, drawing from the lessons of the past."},
{"Number": 99, "Quote Topic": "Love β€οΈ", "Quote": "Love is the universal language, transcending boundaries and touching souls."},
{"Number": 100, "Quote Topic": "Love β€οΈ", "Quote": "Through love, we find connection, unity, and the essence of existence."}
]
# Function to display a quote
def display_quote(quote):
st.markdown(f"### {quote['Number']}. {quote['Quote Topic']}")
st.markdown(quote['Quote'])
# Function to generate a short user hash
def generate_user_hash():
if 'user_hash' not in st.session_state:
session_id = str(random.getrandbits(128))
hash_object = hashlib.md5(session_id.encode())
st.session_state['user_hash'] = hash_object.hexdigest()[:8]
return st.session_state['user_hash']
# Function to load vote history from file
def load_vote_history():
try:
with open('vote_history.json', 'r') as f:
return json.load(f)
except FileNotFoundError:
return {'images': {}, 'users': {}}
# Function to save vote history to file
def save_vote_history(history):
with open('vote_history.json', 'w') as f:
json.dump(history, f)
# Function to update vote history in Markdown file
def update_history_md(image_name, user_hash):
with open('history.md', 'a') as f:
f.write(f"- {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - User {user_hash} voted for {image_name}\n")
# Function to display images
def display_images(image_dir):
col1, col2 = st.columns(2)
valid_extensions = ('.png', '.jpg', '.jpeg', '.gif', '.bmp', '.tiff', '.webp')
images = [f for f in os.listdir(image_dir) if f.lower().endswith(valid_extensions)]
if len(images) < 2:
st.error("Not enough images in the directory.")
return
image1, image2 = random.sample(images, 2)
with col1:
st.image(os.path.join(image_dir, image1))
if st.button(f"Upvote {image1}", key=f"upvote_{image1}"):
handle_vote(image1)
with col2:
st.image(os.path.join(image_dir, image2))
if st.button(f"Upvote {image2}", key=f"upvote_{image2}"):
handle_vote(image2)
# Function to handle voting
def handle_vote(image_name):
user_hash = generate_user_hash()
vote_history = load_vote_history()
if image_name not in vote_history['images']:
vote_history['images'][image_name] = {'votes': 0, 'users': {}}
if user_hash not in vote_history['users']:
vote_history['users'][user_hash] = 0
vote_history['images'][image_name]['votes'] += 1
if user_hash not in vote_history['images'][image_name]['users']:
vote_history['images'][image_name]['users'][user_hash] = 0
vote_history['images'][image_name]['users'][user_hash] += 1
vote_history['users'][user_hash] += 1
save_vote_history(vote_history)
update_history_md(image_name, user_hash)
st.success(f"Upvoted {image_name}! Total votes: {vote_history['images'][image_name]['votes']}")
# Reset the timer when a vote is cast
st.session_state.last_interaction = time.time()
# Function to show vote history and user stats in sidebar
def show_vote_history():
st.sidebar.title("Vote History")
vote_history = load_vote_history()
# Sort users by total votes
sorted_users = sorted(vote_history['users'].items(), key=lambda x: x[1], reverse=True)
st.sidebar.subheader("User Vote Totals")
for user_hash, votes in sorted_users:
st.sidebar.write(f"User {user_hash}: {votes} votes")
# Sort images by vote count
sorted_images = sorted(vote_history['images'].items(), key=lambda x: x[1]['votes'], reverse=True)
st.sidebar.subheader("Image Vote Totals")
for i, (image_name, data) in enumerate(sorted_images):
votes = data['votes']
st.sidebar.write(f"{image_name}: {votes} votes")
# Display top 3 images
if i < 3:
st.sidebar.image(os.path.join('.', image_name), caption=f"#{i+1}: {image_name}", width=150)
# Main function
def main():
st.title("π Super Quote Generator with Image Voting")
st.write("Welcome to the Super Quote Generator! Enjoy famous and custom quotes with advanced features.")
# Initialize session states
if 'auto_repeat' not in st.session_state:
st.session_state.auto_repeat = "On"
if 'current_index' not in st.session_state:
st.session_state.current_index = random.randint(0, 19)
if 'quotes_list' not in st.session_state:
st.session_state.quotes_list = 'Famous Quotes'
if 'quotes_data' not in st.session_state:
st.session_state.quotes_data = pd.DataFrame()
if 'last_interaction' not in st.session_state:
st.session_state.last_interaction = time.time()
# Sidebar configuration
with st.sidebar:
st.header("Settings")
# Data source selection
st.session_state.quotes_list = st.radio("Select Quote Source:", ['Famous Quotes', 'Custom Quotes'])
# AutoRepeat toggle
st.session_state.auto_repeat = st.radio("π AutoRepeat", ["On", "Off"], horizontal=True)
st.markdown("---")
st.write("Famous quotes provided by the app.")
# Display user hash
st.subheader("Your User ID")
st.write(generate_user_hash())
# Show vote history
show_vote_history()
# Load quotes data
if st.session_state.quotes_list == 'Famous Quotes':
st.session_state.quotes_data = load_famous_quotes()
else:
st.session_state.quotes_data = pd.DataFrame(custom_quotes)
# Display images for voting
image_dir = '.' # Current directory where the app is running
display_images(image_dir)
# Display the current quote
st.subheader("Quote of the Moment")
current_quote = st.session_state.quotes_data.iloc[st.session_state.current_index]
display_quote(current_quote)
# Timer logic
if st.session_state.auto_repeat == "On":
timer_placeholder = st.empty()
time_left = 10 - (time.time() - st.session_state.last_interaction)
if time_left <= 0:
# Alternate between the two quotes lists
if st.session_state.quotes_list == 'Famous Quotes':
st.session_state.quotes_list = 'Custom Quotes'
else:
st.session_state.quotes_list = 'Famous Quotes'
# Load the new quotes data
if st.session_state.quotes_list == 'Famous Quotes':
st.session_state.quotes_data = load_famous_quotes()
else:
st.session_state.quotes_data = pd.DataFrame(custom_quotes)
# Select a new random quote
st.session_state.current_index = random.randint(0, len(st.session_state.quotes_data) - 1)
st.session_state.last_interaction = time.time()
st.rerun()
else:
timer_placeholder.text(f"Time left: {int(time_left)} seconds")
else:
st.session_state.last_interaction = time.time()
# Manual refresh button
if st.button("Refresh Now"):
# Alternate between the two quotes lists
if st.session_state.quotes_list == 'Famous Quotes':
st.session_state.quotes_list = 'Custom Quotes'
else:
st.session_state.quotes_list = 'Famous Quotes'
# Load the new quotes data
if st.session_state.quotes_list == 'Famous Quotes':
st.session_state.quotes_data = load_famous_quotes()
else:
st.session_state.quotes_data = pd.DataFrame(custom_quotes)
# Select a new random quote
st.session_state.current_index = random.randint(0, len(st.session_state.quotes_data) - 1)
st.session_state.last_interaction = time.time()
st.rerun()
if __name__ == "__main__":
main() |