Update src/streamlit_app.py
Browse files- src/streamlit_app.py +26 -12
src/streamlit_app.py
CHANGED
|
@@ -173,6 +173,13 @@ LANGUAGES = {
|
|
| 173 |
"mole_fraction": "摩尔分数",
|
| 174 |
"volume_fraction": "体积分数",
|
| 175 |
"mass_fraction": "质量分数",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
"calculation_formula": "📐 计算公式",
|
| 177 |
"formula_mole_to_vol_title": "**摩尔分数转换为体积分数:**",
|
| 178 |
"formula_vol_to_mole_title": "**体积分数转换为摩尔分数:**",
|
|
@@ -232,6 +239,13 @@ LANGUAGES = {
|
|
| 232 |
"mole_fraction": "Mole Fraction",
|
| 233 |
"volume_fraction": "Volume Fraction",
|
| 234 |
"mass_fraction": "Mass Fraction",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
"calculation_formula": "📐 Calculation Formula",
|
| 236 |
"formula_mole_to_vol_title": "**Mole Fraction to Volume Fraction:**",
|
| 237 |
"formula_vol_to_mole_title": "**Volume Fraction to Mole Fraction:**",
|
|
@@ -306,7 +320,7 @@ SOLVENTS_DB = {
|
|
| 306 |
# 语言选择
|
| 307 |
language = st.sidebar.selectbox(
|
| 308 |
"🌐 Language/语言:",
|
| 309 |
-
["
|
| 310 |
help="Choose your preferred language / 选择您的首选语言"
|
| 311 |
)
|
| 312 |
lang = LANGUAGES[language]
|
|
@@ -674,13 +688,13 @@ with col2:
|
|
| 674 |
# 验证信息
|
| 675 |
st.markdown("---")
|
| 676 |
if mole_result:
|
| 677 |
-
st.success(f"✅
|
| 678 |
if vol_result:
|
| 679 |
-
st.success(f"✅
|
| 680 |
if mass_result:
|
| 681 |
-
st.success(f"✅
|
| 682 |
|
| 683 |
-
# 可视化部分
|
| 684 |
st.markdown("---")
|
| 685 |
st.markdown(f"### {lang['visualization']}")
|
| 686 |
|
|
@@ -691,9 +705,9 @@ if mole_result:
|
|
| 691 |
fig.add_trace(go.Pie(
|
| 692 |
labels=[solvent_a_name, solvent_b_name],
|
| 693 |
values=[mole_result[0], mole_result[1]],
|
| 694 |
-
name="
|
| 695 |
domain=dict(x=[0, 0.3]),
|
| 696 |
-
title="
|
| 697 |
marker_colors=[current_solvents.get(solvent_a_name, {}).get('color', '#3498db'),
|
| 698 |
current_solvents.get(solvent_b_name, {}).get('color', '#e74c3c')]
|
| 699 |
))
|
|
@@ -702,9 +716,9 @@ if vol_result:
|
|
| 702 |
fig.add_trace(go.Pie(
|
| 703 |
labels=[solvent_a_name, solvent_b_name],
|
| 704 |
values=[vol_result[0], vol_result[1]],
|
| 705 |
-
name="
|
| 706 |
domain=dict(x=[0.35, 0.65]),
|
| 707 |
-
title="
|
| 708 |
marker_colors=[current_solvents.get(solvent_a_name, {}).get('color', '#3498db'),
|
| 709 |
current_solvents.get(solvent_b_name, {}).get('color', '#e74c3c')]
|
| 710 |
))
|
|
@@ -713,16 +727,16 @@ if mass_result:
|
|
| 713 |
fig.add_trace(go.Pie(
|
| 714 |
labels=[solvent_a_name, solvent_b_name],
|
| 715 |
values=[mass_result[0], mass_result[1]],
|
| 716 |
-
name="
|
| 717 |
domain=dict(x=[0.7, 1.0]),
|
| 718 |
-
title="
|
| 719 |
marker_colors=[current_solvents.get(solvent_a_name, {}).get('color', '#3498db'),
|
| 720 |
current_solvents.get(solvent_b_name, {}).get('color', '#e74c3c')]
|
| 721 |
))
|
| 722 |
|
| 723 |
fig.update_traces(textposition='inside', textinfo='percent+label')
|
| 724 |
fig.update_layout(
|
| 725 |
-
title_text="
|
| 726 |
showlegend=False,
|
| 727 |
height=400,
|
| 728 |
margin=dict(l=20, r=20, t=50, b=20)
|
|
|
|
| 173 |
"mole_fraction": "摩尔分数",
|
| 174 |
"volume_fraction": "体积分数",
|
| 175 |
"mass_fraction": "质量分数",
|
| 176 |
+
"mole_verification": "摩尔分数验证",
|
| 177 |
+
"volume_verification": "体积分数验证",
|
| 178 |
+
"mass_verification": "质量分数验证",
|
| 179 |
+
"fraction_visualization": "溶剂分数可视化",
|
| 180 |
+
"mole_fraction_chart": "摩尔分数",
|
| 181 |
+
"volume_fraction_chart": "体积分数",
|
| 182 |
+
"mass_fraction_chart": "质量分数",
|
| 183 |
"calculation_formula": "📐 计算公式",
|
| 184 |
"formula_mole_to_vol_title": "**摩尔分数转换为体积分数:**",
|
| 185 |
"formula_vol_to_mole_title": "**体积分数转换为摩尔分数:**",
|
|
|
|
| 239 |
"mole_fraction": "Mole Fraction",
|
| 240 |
"volume_fraction": "Volume Fraction",
|
| 241 |
"mass_fraction": "Mass Fraction",
|
| 242 |
+
"mole_verification": "Mole Fraction Verification",
|
| 243 |
+
"volume_verification": "Volume Fraction Verification",
|
| 244 |
+
"mass_verification": "Mass Fraction Verification",
|
| 245 |
+
"fraction_visualization": "Solvent Fraction Visualization",
|
| 246 |
+
"mole_fraction_chart": "Mole Fraction",
|
| 247 |
+
"volume_fraction_chart": "Volume Fraction",
|
| 248 |
+
"mass_fraction_chart": "Mass Fraction",
|
| 249 |
"calculation_formula": "📐 Calculation Formula",
|
| 250 |
"formula_mole_to_vol_title": "**Mole Fraction to Volume Fraction:**",
|
| 251 |
"formula_vol_to_mole_title": "**Volume Fraction to Mole Fraction:**",
|
|
|
|
| 320 |
# 语言选择
|
| 321 |
language = st.sidebar.selectbox(
|
| 322 |
"🌐 Language/语言:",
|
| 323 |
+
["中文", "English"],
|
| 324 |
help="Choose your preferred language / 选择您的首选语言"
|
| 325 |
)
|
| 326 |
lang = LANGUAGES[language]
|
|
|
|
| 688 |
# 验证信息
|
| 689 |
st.markdown("---")
|
| 690 |
if mole_result:
|
| 691 |
+
st.success(f"✅ {lang['mole_verification']}: {mole_result[0] + mole_result[1]:.6f}")
|
| 692 |
if vol_result:
|
| 693 |
+
st.success(f"✅ {lang['volume_verification']}: {vol_result[0] + vol_result[1]:.6f}")
|
| 694 |
if mass_result:
|
| 695 |
+
st.success(f"✅ {lang['mass_verification']}: {mass_result[0] + mass_result[1]:.6f}")
|
| 696 |
|
| 697 |
+
# 可视化部分修改
|
| 698 |
st.markdown("---")
|
| 699 |
st.markdown(f"### {lang['visualization']}")
|
| 700 |
|
|
|
|
| 705 |
fig.add_trace(go.Pie(
|
| 706 |
labels=[solvent_a_name, solvent_b_name],
|
| 707 |
values=[mole_result[0], mole_result[1]],
|
| 708 |
+
name=lang["mole_fraction_chart"],
|
| 709 |
domain=dict(x=[0, 0.3]),
|
| 710 |
+
title=lang["mole_fraction_chart"],
|
| 711 |
marker_colors=[current_solvents.get(solvent_a_name, {}).get('color', '#3498db'),
|
| 712 |
current_solvents.get(solvent_b_name, {}).get('color', '#e74c3c')]
|
| 713 |
))
|
|
|
|
| 716 |
fig.add_trace(go.Pie(
|
| 717 |
labels=[solvent_a_name, solvent_b_name],
|
| 718 |
values=[vol_result[0], vol_result[1]],
|
| 719 |
+
name=lang["volume_fraction_chart"],
|
| 720 |
domain=dict(x=[0.35, 0.65]),
|
| 721 |
+
title=lang["volume_fraction_chart"],
|
| 722 |
marker_colors=[current_solvents.get(solvent_a_name, {}).get('color', '#3498db'),
|
| 723 |
current_solvents.get(solvent_b_name, {}).get('color', '#e74c3c')]
|
| 724 |
))
|
|
|
|
| 727 |
fig.add_trace(go.Pie(
|
| 728 |
labels=[solvent_a_name, solvent_b_name],
|
| 729 |
values=[mass_result[0], mass_result[1]],
|
| 730 |
+
name=lang["mass_fraction_chart"],
|
| 731 |
domain=dict(x=[0.7, 1.0]),
|
| 732 |
+
title=lang["mass_fraction_chart"],
|
| 733 |
marker_colors=[current_solvents.get(solvent_a_name, {}).get('color', '#3498db'),
|
| 734 |
current_solvents.get(solvent_b_name, {}).get('color', '#e74c3c')]
|
| 735 |
))
|
| 736 |
|
| 737 |
fig.update_traces(textposition='inside', textinfo='percent+label')
|
| 738 |
fig.update_layout(
|
| 739 |
+
title_text=lang["fraction_visualization"],
|
| 740 |
showlegend=False,
|
| 741 |
height=400,
|
| 742 |
margin=dict(l=20, r=20, t=50, b=20)
|