Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -778,6 +778,7 @@ def enhanced_likert_scale(question_data):
|
|
| 778 |
justify-content: center !important;
|
| 779 |
gap: 8px !important;
|
| 780 |
margin: 0 !important;
|
|
|
|
| 781 |
position: relative !important;
|
| 782 |
height: 40px !important;
|
| 783 |
}}
|
|
@@ -852,7 +853,7 @@ def enhanced_likert_scale(question_data):
|
|
| 852 |
<div class="likert-buttons" id="likert-buttons-{key}">
|
| 853 |
"""
|
| 854 |
|
| 855 |
-
# محاسبه موقعیت دکمهها
|
| 856 |
button_width = 40
|
| 857 |
gap = 8
|
| 858 |
total_width = scale * button_width + (scale - 1) * gap
|
|
@@ -892,62 +893,61 @@ def enhanced_likert_scale(question_data):
|
|
| 892 |
components.html(html_content, height=150)
|
| 893 |
|
| 894 |
# ایجاد دکمههای Streamlit
|
| 895 |
-
|
| 896 |
for i in range(scale):
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 900 |
st.markdown(
|
| 901 |
f"""
|
| 902 |
-
<
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
width: 40px !important;
|
| 906 |
-
height: 40px !important;
|
| 907 |
-
margin: 0 !important;
|
| 908 |
-
padding: 0 !important;
|
| 909 |
-
}}
|
| 910 |
-
#streamlit-btn-{key}-{value} {{
|
| 911 |
-
width: 40px !important;
|
| 912 |
-
height: 40px !important;
|
| 913 |
-
opacity: 0 !important;
|
| 914 |
-
position: absolute !important;
|
| 915 |
-
top: 0 !important;
|
| 916 |
-
left: 0 !important;
|
| 917 |
-
margin: 0 !important;
|
| 918 |
-
padding: 0 !important;
|
| 919 |
-
border: none !important;
|
| 920 |
-
background: white !important;
|
| 921 |
-
z-index: 1 !important;
|
| 922 |
-
}}
|
| 923 |
-
#streamlit-btn-{key}-{value}:hover,
|
| 924 |
-
#streamlit-btn-{key}-{value}:focus,
|
| 925 |
-
#streamlit-btn-{key}-{value}:active {{
|
| 926 |
-
border: none !important;
|
| 927 |
-
background: white !important;
|
| 928 |
-
}}
|
| 929 |
-
</style>
|
| 930 |
-
<div class="likert-streamlit-btn-container-{key}-{value}"></div>
|
| 931 |
""",
|
| 932 |
unsafe_allow_html=True
|
| 933 |
)
|
| 934 |
-
|
| 935 |
-
|
| 936 |
-
key=f"streamlit-btn-{key}-{value}",
|
| 937 |
-
help=str(value),
|
| 938 |
-
type="secondary"
|
| 939 |
-
):
|
| 940 |
-
st.session_state[key] = value
|
| 941 |
-
# آپدیت دکمههای HTML با JavaScript
|
| 942 |
-
st.markdown(
|
| 943 |
-
f"""
|
| 944 |
-
<script>
|
| 945 |
-
updateLikertSelection('{key}', {value});
|
| 946 |
-
</script>
|
| 947 |
-
""",
|
| 948 |
-
unsafe_allow_html=True
|
| 949 |
-
)
|
| 950 |
-
st.rerun()
|
| 951 |
|
| 952 |
return st.session_state.get(key)
|
| 953 |
|
|
|
|
| 778 |
justify-content: center !important;
|
| 779 |
gap: 8px !important;
|
| 780 |
margin: 0 !important;
|
| 781 |
+
padding: 0 !important;
|
| 782 |
position: relative !important;
|
| 783 |
height: 40px !important;
|
| 784 |
}}
|
|
|
|
| 853 |
<div class="likert-buttons" id="likert-buttons-{key}">
|
| 854 |
"""
|
| 855 |
|
| 856 |
+
# محاسبه موقعیت دکمهها
|
| 857 |
button_width = 40
|
| 858 |
gap = 8
|
| 859 |
total_width = scale * button_width + (scale - 1) * gap
|
|
|
|
| 893 |
components.html(html_content, height=150)
|
| 894 |
|
| 895 |
# ایجاد دکمههای Streamlit
|
| 896 |
+
st.markdown('<div style="display: flex; justify-content: center; gap: 8px; margin: 0; padding: 0;">', unsafe_allow_html=True)
|
| 897 |
for i in range(scale):
|
| 898 |
+
value = scale - i # 7 تا 1
|
| 899 |
+
st.markdown(
|
| 900 |
+
f"""
|
| 901 |
+
<style>
|
| 902 |
+
.likert-streamlit-btn-container-{key}-{value} {{
|
| 903 |
+
position: relative !important;
|
| 904 |
+
width: 40px !important;
|
| 905 |
+
height: 40px !important;
|
| 906 |
+
margin: 0 !important;
|
| 907 |
+
padding: 0 !important;
|
| 908 |
+
}}
|
| 909 |
+
#streamlit-btn-{key}-{value} {{
|
| 910 |
+
width: 40px !important;
|
| 911 |
+
height: 40px !important;
|
| 912 |
+
opacity: 0 !important;
|
| 913 |
+
position: absolute !important;
|
| 914 |
+
top: 0 !important;
|
| 915 |
+
left: 0 !important;
|
| 916 |
+
margin: 0 !important;
|
| 917 |
+
padding: 0 !important;
|
| 918 |
+
border: none !important;
|
| 919 |
+
background: white !important;
|
| 920 |
+
z-index: 1 !important;
|
| 921 |
+
}}
|
| 922 |
+
#streamlit-btn-{key}-{value}:hover,
|
| 923 |
+
#streamlit-btn-{key}-{value}:focus,
|
| 924 |
+
#streamlit-btn-{key}-{value}:active {{
|
| 925 |
+
border: none !important;
|
| 926 |
+
background: white !important;
|
| 927 |
+
}}
|
| 928 |
+
</style>
|
| 929 |
+
<div class="likert-streamlit-btn-container-{key}-{value}"></div>
|
| 930 |
+
""",
|
| 931 |
+
unsafe_allow_html=True
|
| 932 |
+
)
|
| 933 |
+
if st.button(
|
| 934 |
+
"•" if st.session_state[key] == value else "○",
|
| 935 |
+
key=f"streamlit-btn-{key}-{value}",
|
| 936 |
+
help=str(value),
|
| 937 |
+
type="secondary"
|
| 938 |
+
):
|
| 939 |
+
st.session_state[key] = value
|
| 940 |
+
# آپدیت دکمههای HTML با JavaScript
|
| 941 |
st.markdown(
|
| 942 |
f"""
|
| 943 |
+
<script>
|
| 944 |
+
updateLikertSelection('{key}', {value});
|
| 945 |
+
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 946 |
""",
|
| 947 |
unsafe_allow_html=True
|
| 948 |
)
|
| 949 |
+
st.rerun()
|
| 950 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 951 |
|
| 952 |
return st.session_state.get(key)
|
| 953 |
|