-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
127 lines (110 loc) · 4.03 KB
/
test.py
File metadata and controls
127 lines (110 loc) · 4.03 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
from contextlib import contextmanager
import streamlit as st
import jobs
HORIZONTAL_STYLE = """
<style class="hide-element">
/* Hides the style container and removes the extra spacing */
.element-container:has(.hide-element) {
display: none;
}
/*
The selector for >.element-container is necessary to avoid selecting the whole
body of the streamlit app, which is also a stVerticalBlock.
*/
div[data-testid="stVerticalBlock"]:has(> .element-container .horizontal-marker) {
display: flex;
flex-direction: row !important;
flex-wrap: wrap;
gap: 0.5rem;
align-items: baseline;
}
/* Buttons and their parent container all have a width of 704px, which we need to override */
div[data-testid="stVerticalBlock"]:has(> .element-container .horizontal-marker) div {
width: max-content !important;
}
/* Just an example of how you would style buttons, if desired */
/*
div[data-testid="stVerticalBlock"]:has(> .element-container .horizontal-marker) button {
border-color: red;
}
div[data-testid="stVerticalBlock"]:has(> .element-container .horizontal-marker) input {
width: 50px important;
}
*/
</style>
"""
RECORD_KEY="scout_record"
class ScoutingRecord(object):
def __init__(self):
self.L1success = 0
self.L2fails = 0
st.markdown(
"""
<style>
/* Target number input fields */
input[type="number"] {
width: 35px;
}
input[type="text"]{
width: 70px;
}
</style>
""",
unsafe_allow_html=True,
)
@contextmanager
def st_horizontal():
st.markdown(HORIZONTAL_STYLE, unsafe_allow_html=True)
with st.container():
st.markdown('<span class="hide-element horizontal-marker"></span>', unsafe_allow_html=True)
yield
if RECORD_KEY in st.session_state:
rec = st.session_state[RECORD_KEY]
else:
rec = ScoutingRecord()
st.session_state[RECORD_KEY] = rec
def add_L1_fail():
rec.L2fails += 1
def add_L1_success():
rec.L1success += 1
st.header("Scouting Form")
with st.form("match_record"):
with st_horizontal():
st.text_input("scout",max_chars=2)
st.selectbox("Match",("Q1","Q2","Q3","Q4"))
st.selectbox("Team", ("281", "4451", "342", "343"))
st.divider()
with st_horizontal():
st.checkbox("Move")
st.number_input(label="Coral",key='qqqf',min_value=1,max_value=50,step=1)
st.divider()
with st_horizontal():
st.number_input(label="✅ L1 Coral",key='f',min_value=1,max_value=50,step=1)
st.number_input(label="✅ L2 Coral",key='t',min_value=1,max_value=50,step=1)
st.number_input(label="✅ L3 Coral",key='ttt',min_value=1,max_value=50,step=1)
st.number_input(label="✅ L4 Coral",key='ssss',min_value=1,max_value=50,step=1)
with st_horizontal():
st.number_input(label="❌ L1 Coral",key='af',min_value=1,max_value=50,step=1)
st.number_input(label="❌ L2 Coral",key='at',min_value=1,max_value=50,step=1)
st.number_input(label="❌ L3 Coral",key='attt',min_value=1,max_value=50,step=1)
st.number_input(label="❌ L4 Coral",key='assss',min_value=1,max_value=50,step=1)
with st_horizontal():
st.number_input(label="Algae Dislodge",key='bf',min_value=1,max_value=50,step=1)
st.number_input(label="Algae Process",key='bt',min_value=1,max_value=50,step=1)
st.number_input(label="Algae Barge",key='bttt',min_value=1,max_value=50,step=1)
with st_horizontal():
st.number_input(label="Penalties",key='baaf',min_value=1,max_value=50,step=1)
st.divider()
options = ["Park", "Shallow", "Deep"]
with st_horizontal():
st.checkbox("Ground Pickup")
st.checkbox("amazing thing")
st.divider()
selection = st.segmented_control(
"End Game", options, selection_mode="single"
)
st.divider()
f = st.form_submit_button("Submit")
if f:
print (f"ScoutingRecord: Fails={rec.L2fails}, success={rec.L1success}")
st.session_state[RECORD_KEY] = ScoutingRecord()