-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyFirstStreamlit.py
More file actions
133 lines (108 loc) · 3.94 KB
/
MyFirstStreamlit.py
File metadata and controls
133 lines (108 loc) · 3.94 KB
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
import streamlit as st
import pandas as pd
import numpy as np
col1, col2, col3 = st.columns(3)
# Initialize session state for ratings at the start of the script
if 'ratings' not in st.session_state:
st.session_state['ratings'] = {
"Luffy": 0,
"Nami": 0,
"Robin": 0,
"Zoro": 0,
"Usopp": 0,
"Franky": 0,
"Jinbie": 0,
"Sanji": 0,
"Chopper": 0,
"Brook": 0
}
def update_rating(character):
st.session_state['ratings'][character] += 1
st.toast(f"Thank you for rating {character}!")
st.sidebar.title("One Piece Character Favorite")
st.sidebar.markdown("Straw Hat Crew")
text = st.sidebar.text_area("Please Inpur your Name")
if st.sidebar.button("Click to State Your Name"):
st.toast(f"Hello {text}, please vote wisely!")
# Col 1
with col1:
luffy = "Pictures/luffy.jpeg"
nami = "Pictures/Nami.jpeg"
robin = "Pictures/Robin.jpeg"
with st.container():
st.image(luffy, use_column_width=True)
st.markdown("Monkey D. Luffy")
st.write("3,000,000,000 Bounty")
if st.button("Click Me to Rate!", key='b1'):
update_rating("Luffy")
with st.container():
st.image(nami, use_column_width=True)
st.markdown("Nami")
st.write("366,000,000 Bounty")
if st.button("Click Me to Rate!", key='b4'):
update_rating("Nami")
with st.container():
st.image(robin, use_column_width=True)
st.markdown("Nico Robin")
st.write("930,000,000 Bounty")
if st.button("Click Me to Rate!", key='b7'):
update_rating("Robin")
# Col 2
with col2:
zoro = "Pictures/zoro.jpeg"
usopp = "Pictures/Usopp.jpeg"
franky = "Pictures/Franky.jpeg"
jinbie = "Pictures/Jinbie.jpeg"
with st.container():
st.image(zoro, use_column_width=True)
st.markdown("Ronoroa Zoro")
st.write("1,111,000,000 Bounty")
if st.button("Click Me to Rate!", key='b2'):
update_rating("Zoro")
with st.container():
st.image(usopp, use_column_width=True)
st.markdown("God Usopp")
st.write("500,000,000 Bounty")
if st.button("Click Me to Rate!", key='b5'):
update_rating("Usopp")
with st.container():
st.image(franky, use_column_width=True)
st.markdown("Franky")
st.write("394,000,000 Bounty")
if st.button("Click Me to Rate!", key='b8'):
update_rating("Franky")
with st.container():
st.image(jinbie, use_column_width=True)
st.markdown("Jinbie")
st.write("1,100,000,000 Bounty")
if st.button("Click Me to Rate!", key='b10'):
update_rating("Jinbie")
# Col 3
with col3:
sanji = "Pictures/Sanji.jpeg"
chopper = "Pictures/Chopper.jpg"
brook = "Pictures/Brook.jpg"
with st.container():
st.image(sanji, use_column_width=True)
st.markdown("Vinsmoke Sanji")
st.write("1,032,000,000 Bounty")
if st.button("Click Me to Rate!", key='b3'):
update_rating("Sanji")
with st.container():
st.image(chopper, use_column_width=True)
st.markdown("Tony Tony Chopper")
st.write("1,000 Bounty")
if st.button("Click Me to Rate!", key='b6'):
update_rating("Chopper")
with st.container():
st.image(brook, use_column_width=True)
st.markdown("Brook")
st.write("383,000,000 Bounty")
if st.button("Click Me to Rate!", key='b9'):
update_rating("Brook")
st.sidebar.markdown("# Total Ratings")
for character, count in st.session_state['ratings'].items():
st.sidebar.write(f"{character}: {count}")
tocontact = st.sidebar.selectbox("How would you like to Contacted?", ("","Email", "Mobile Phone Number"))
if tocontact:
st.toast("Hi Thank you for Donations " +tocontact)