Update app.py
Browse files
app.py
CHANGED
@@ -1,39 +1,47 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
st.
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
st.
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
# Auto-refresh the app based on the slider value
|
38 |
-
st.experimental_set_query_params(refresh_rate=refresh_rate)
|
39 |
-
st.stop() # Prevents an infinite loop of refresh
|
|
|
1 |
+
# app.py
|
2 |
import streamlit as st
|
3 |
+
|
4 |
+
def adjust_ratios(components):
|
5 |
+
"""Adjusts the ratio of each component."""
|
6 |
+
st.write("### Adjust Air Mixture Components")
|
7 |
+
adjusted_components = {}
|
8 |
+
for component, value in components.items():
|
9 |
+
adjusted_value = st.slider(
|
10 |
+
label=f"{component} Ratio (%)", min_value=0, max_value=100, value=int(value)
|
11 |
+
)
|
12 |
+
adjusted_components[component] = adjusted_value
|
13 |
+
return adjusted_components
|
14 |
+
|
15 |
+
def main():
|
16 |
+
st.title("Air Mixture Adjustment App")
|
17 |
+
st.write("This app allows you to sense and adjust the ratio of each component in an air mixture.")
|
18 |
+
|
19 |
+
# Simulate sensing air mixture (replace with actual sensing functionality if available)
|
20 |
+
st.write("### Sensed Air Components")
|
21 |
+
sensed_components = {
|
22 |
+
"Nitrogen": 78,
|
23 |
+
"Oxygen": 21,
|
24 |
+
"Carbon Dioxide": 0.04,
|
25 |
+
"Argon": 0.93
|
26 |
}
|
27 |
+
|
28 |
+
# Display sensed components
|
29 |
+
for component, value in sensed_components.items():
|
30 |
+
st.write(f"{component}: {value}%")
|
31 |
+
|
32 |
+
# Adjust components
|
33 |
+
adjusted_components = adjust_ratios(sensed_components)
|
34 |
+
|
35 |
+
# Ensure the sum of the components is 100%
|
36 |
+
total = sum(adjusted_components.values())
|
37 |
+
if total != 100:
|
38 |
+
st.warning("The total percentage does not equal 100%. Please adjust the values.")
|
39 |
+
|
40 |
+
# Display adjusted components
|
41 |
+
st.write("### Final Adjusted Components")
|
42 |
+
for component, value in adjusted_components.items():
|
43 |
+
st.write(f"{component}: {value}%")
|
44 |
+
|
45 |
+
if __name__ == "__main__":
|
46 |
+
main()
|
47 |
+
|
|
|
|
|
|
|
|