# app.py import streamlit as st def adjust_ratios(components): """Adjusts the ratio of each component.""" st.write("### Adjust Air Mixture Components") adjusted_components = {} for component, value in components.items(): adjusted_value = st.slider( label=f"{component} Ratio (%)", min_value=0, max_value=100, value=int(value) ) adjusted_components[component] = adjusted_value return adjusted_components def main(): st.title("Air Mixture Adjustment App") st.write("This app allows you to sense and adjust the ratio of each component in an air mixture.") # Simulate sensing air mixture (replace with actual sensing functionality if available) st.write("### Sensed Air Components") sensed_components = { "Nitrogen": 78, "Oxygen": 21, "Carbon Dioxide": 0.04, "Argon": 0.93 } # Display sensed components for component, value in sensed_components.items(): st.write(f"{component}: {value}%") # Adjust components adjusted_components = adjust_ratios(sensed_components) # Ensure the sum of the components is 100% total = sum(adjusted_components.values()) if total != 100: st.warning("The total percentage does not equal 100%. Please adjust the values.") # Display adjusted components st.write("### Final Adjusted Components") for component, value in adjusted_components.items(): st.write(f"{component}: {value}%") if __name__ == "__main__": main()