Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -786,6 +786,9 @@ def enhanced_likert_scale(question_data):
|
|
| 786 |
st.markdown(f"<div style='text-align:center; font-weight:bold; margin-bottom:15px;'>{question}</div>",
|
| 787 |
unsafe_allow_html=True)
|
| 788 |
|
|
|
|
|
|
|
|
|
|
| 789 |
# ایجاد کامپوننت تعاملی با JavaScript
|
| 790 |
scale_html = f"""
|
| 791 |
<!DOCTYPE html>
|
|
@@ -830,12 +833,6 @@ def enhanced_likert_scale(question_data):
|
|
| 830 |
font-weight: bold;
|
| 831 |
color: #6a0dad;
|
| 832 |
}}
|
| 833 |
-
.separator-line {{
|
| 834 |
-
width: 100%;
|
| 835 |
-
height: 2px;
|
| 836 |
-
background: #6a0dad;
|
| 837 |
-
margin: 20px 0;
|
| 838 |
-
}}
|
| 839 |
</style>
|
| 840 |
</head>
|
| 841 |
<body>
|
|
@@ -879,10 +876,13 @@ def enhanced_likert_scale(question_data):
|
|
| 879 |
dot.classList.add('active');
|
| 880 |
|
| 881 |
// ارسال مقدار به Streamlit
|
| 882 |
-
|
|
|
|
|
|
|
|
|
|
| 883 |
key: key,
|
| 884 |
value: i
|
| 885 |
-
}});
|
| 886 |
}});
|
| 887 |
|
| 888 |
line.appendChild(dot);
|
|
@@ -900,10 +900,10 @@ def enhanced_likert_scale(question_data):
|
|
| 900 |
"""
|
| 901 |
|
| 902 |
# نمایش کامپوننت و دریافت مقدار
|
| 903 |
-
value = components.html(scale_html, height=120
|
| 904 |
|
| 905 |
-
#
|
| 906 |
-
if
|
| 907 |
st.session_state[key] = value["value"]
|
| 908 |
st.experimental_rerun()
|
| 909 |
|
|
|
|
| 786 |
st.markdown(f"<div style='text-align:center; font-weight:bold; margin-bottom:15px;'>{question}</div>",
|
| 787 |
unsafe_allow_html=True)
|
| 788 |
|
| 789 |
+
# ایجاد یک کلید منحصر به فرد برای کامپوننت
|
| 790 |
+
component_key = f"{key}_component"
|
| 791 |
+
|
| 792 |
# ایجاد کامپوننت تعاملی با JavaScript
|
| 793 |
scale_html = f"""
|
| 794 |
<!DOCTYPE html>
|
|
|
|
| 833 |
font-weight: bold;
|
| 834 |
color: #6a0dad;
|
| 835 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 836 |
</style>
|
| 837 |
</head>
|
| 838 |
<body>
|
|
|
|
| 876 |
dot.classList.add('active');
|
| 877 |
|
| 878 |
// ارسال مقدار به Streamlit
|
| 879 |
+
window.parent.postMessage({{
|
| 880 |
+
isStreamlitMessage: true,
|
| 881 |
+
type: 'streamlit:setComponentValue',
|
| 882 |
+
api: "1.0",
|
| 883 |
key: key,
|
| 884 |
value: i
|
| 885 |
+
}}, "*");
|
| 886 |
}});
|
| 887 |
|
| 888 |
line.appendChild(dot);
|
|
|
|
| 900 |
"""
|
| 901 |
|
| 902 |
# نمایش کامپوننت و دریافت مقدار
|
| 903 |
+
value = components.html(scale_html, height=120)
|
| 904 |
|
| 905 |
+
# گوش دادن به پیامهای از کامپوننت
|
| 906 |
+
if isinstance(value, dict) and value.get("key") == key:
|
| 907 |
st.session_state[key] = value["value"]
|
| 908 |
st.experimental_rerun()
|
| 909 |
|