Spaces:
Sleeping
Sleeping
File size: 3,100 Bytes
9caeaea df39da2 c7f5617 df39da2 c7f5617 df39da2 c7f5617 9caeaea c7f5617 9caeaea |
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 |
import streamlit as st
# Set Streamlit configuration to use the dark theme
def set_theme():
# Create a custom dark theme using Streamlit's theming API
# Adjust the color values according to your preference
primaryColor = "#E694FF"
backgroundColor = "#00172B"
secondaryBackgroundColor = "#0083B8"
textColor = "#FFFFFF"
font = "sans serif"
# Apply the theme settings
st.set_page_config(
theme={
'primaryColor': primaryColor,
'backgroundColor': backgroundColor,
'secondaryBackgroundColor': secondaryBackgroundColor,
'textColor': textColor,
'font': font
}
)
# Call the function to set the theme
set_theme()
ss = st.session_state
GC_NAMES = ['Hydrogen sulphide',
'Carbone dioxide', 'Nitrogen', 'Methane', 'Ethane', 'Propane', 'N-butane', 'Iso-butane', 'N-pentane',
'Iso-pentane', 'N-hexane',
'N-heptane', 'C7+', 'Hydrogen', 'Air', 'Water', 'Oxygen']
center_html = """
<div style='display: flex; flex-direction: column; justify-content: center;; height: 38px;'>
<span style='text-align: center; word-wrap: break-word;'>{}</span>
</div>
"""
sg_k = 'sg_value'
pc_k = 'p_crit_value'
tc_k = 't_crit_value'
gc_state_k = 'gc_state'
for key in [sg_k, pc_k, tc_k]:
if key not in ss:
ss[key] = 0
# Display the selected options
if st.button("Rerun"):
st.rerun()
if st.button("Calculate"):
ss[sg_k] = 30
# Force a rerun to update the display
# st.rerun()
UD = "User defined"
SG_LIST = [UD,
"Gas components",
"Condensate"]
SG_UD, SG_GC, SG_CON = SG_LIST
# Dropdown 1 with options A and B
sg_source = st.selectbox("sg source", SG_LIST)
if sg_source == UD:
user_input = st.text_input("sg", value=ss[sg_k], key="input_field")
ss[sg_k] = user_input
else:
st.text_input("sg", value=ss[sg_k], key="input_field", disabled=True, help="Calculated")
params = []
ss[gc_state_k] = UD
if sg_source != SG_GC:
cur_gc = GC_NAMES[:3]
else:
cur_gc = GC_NAMES
with st.expander("Gas components") as gc_exp:
for i in range(0, len(cur_gc), 3):
cols = st.columns(3)
j = i
for col in cols:
if j >= len(cur_gc):
break
gc11, gc12 = col.columns([1, 1.5])
gc11.markdown(center_html.format(cur_gc[j]), unsafe_allow_html=True)
params.append(gc12.text_input(cur_gc[j], value=0, label_visibility='collapsed'))
j += 1
CRIT_LIST = [UD]
CORRS = ["Sutton", "Standing wet gas", "standing natural gas"]
crit_options = [UD]
if sg_source == SG_GC:
crit_options.append("From gas components")
else:
for c in CORRS:
crit_options.append(c)
crit_params_source = st.selectbox("Critical params", crit_options)
# Create two columns for input fields
col1, col2 = st.columns(2)
if crit_params_source == UD:
dis = False
else:
dis = True
# Add input fields to the columns
param1 = col1.text_input('Pcrit', value=ss[tc_k], disabled=dis)
param2 = col2.text_input('Tcrit', value=ss[pc_k], disabled=dis)
|