awacke1's picture
Update app.py
fb6156b
raw
history blame
3.08 kB
import streamlit as st
from PIL import Image
# Define pages
pages = {
'page1': {
'text': "You are a brave hero on a quest to save the princess. You must travel through a dangerous forest to reach the castle where she is being held captive. Do you want to go left or right?",
'left': 'page2',
'right': 'page3',
'image': 'Aaron_Wacker_Peter_Paul_Rubens_Masterpieces_muscle_monsters_05402d99-cc69-4f6a-965c-fcb08953aa56.png'
},
'page2': {
'text': "You chose to go left. You come across a river. Do you want to swim across or build a raft?",
'left': 'page4',
'right': 'page5',
'image': 'Aaron_Wacker_Phoenix_Launch.png'
},
'page3': {
'text': "You chose to go right. You come across a pack of wolves. Do you want to fight them or run away?",
'left': 'page6',
'right': 'page7',
'image': 'Aaron_Wacker_knight_in_full_platemail_chrome_armor_shining_and__2722e7a1-be10-416b-9d5e-b41da14216d8.png'
},
'page4': {
'text': "You chose to swim across. You make it to the other side safely.",
'left': 'page8',
'right': 'page8',
'image': 'Aaron_Wacker_knight_in_full_platemail_chrome_armor_shining_and__3404dccb-d712-4027-a53e-63834b38bb05.png'
},
'page5': {
'text': "You chose to build a raft. It takes a while, but you eventually make it across the river safely.",
'left': 'page8',
'right': 'page8',
'image': 'Aaron_Wacker_knight_in_full_platemail_chrome_armor_shining_and__e110f029-9dea-4f34-bc78-1e92ef186d23.png'
},
'page6': {
'text': "You chose to fight the wolves. You defeat them, but you sustain some injuries in the process.",
'left': 'page8',
'right': 'page8',
'image': 'Aaron_Wacker_oil_painting_impasto_luminous_masterpiece_peter_pa_8fd22bdd-cff4-4486-b125-6e2831ee1cce.png'
},
'page7': {
'text': "You chose to run away. You escape the wolves, but you get lost in the forest.",
'left': 'page8',
'right': 'page8',
'image': 'Aaron_Wacker_quantum_gate_singularity_transmission_to_earth_hum_5ee55a62-c6ba-435c-a4aa-c843b29be775.png'
},
'page8': {
'text': "You continue on your journey and eventually reach the castle where the princess is being held. You rescue her and she rewards you with a chest full of gold.",
'left': None,
'right': None,
'image': 'Aaron_Wacker_quantum_gate_singularity_transmission_to_earth_hum_d03f6f79-1151-4393-ab1a-fb5e1bead2ec.png'
}
}
# Define show_page function
def show_page(page_name):
page = pages[page_name]
image = Image.open(page['image'])
st.image(image, caption='', use_column_width=True)
st.write(page['text'])
if page['left'] is not None:
if st.button('Go left', key=hash(page['left'])):
show_page(page['left'])
if page['right'] is not None:
if st.button('Go right', key=hash(page['right'])):
show_page(page['right'])
# Render initial page
show_page('page1')