Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -803,40 +803,18 @@ def enhanced_likert_scale(question_data):
|
|
| 803 |
|
| 804 |
for i in range(scale):
|
| 805 |
with cols[i + 2]: # شروع از ستون دوم (پس از برچسبها)
|
| 806 |
-
|
| 807 |
-
|
| 808 |
-
|
| 809 |
-
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
{options[i]}
|
| 813 |
-
</button>
|
| 814 |
-
<script>
|
| 815 |
-
window.addEventListener('message', function(event) {{
|
| 816 |
-
if (event.data.type === 'button_click') {{
|
| 817 |
-
parent.window.parent.postMessage({{type: 'update_session', key: '{key}', value: event.data.value}}, '*');
|
| 818 |
-
}}
|
| 819 |
-
}});
|
| 820 |
-
// بررسی اولیه برای مقدار فعلی
|
| 821 |
-
if ({selected_value} === {int(options[i])}) {{
|
| 822 |
-
document.querySelector('.likert-button[data-value="{options[i]}"]').disabled = false;
|
| 823 |
-
document.querySelector('.likert-button[data-value="{options[i]}"]').style.backgroundColor = '#6a0dad';
|
| 824 |
-
document.querySelector('.likert-button[data-value="{options[i]}"]').style.color = '#fff';
|
| 825 |
-
}}
|
| 826 |
-
</script>
|
| 827 |
-
"""
|
| 828 |
-
st.components.v1.html(button_html, height=40)
|
| 829 |
|
| 830 |
# نمایش برچسب سمت چپ
|
| 831 |
with cols[1]:
|
| 832 |
st.markdown(f"<div style='text-align:left; font-size:14px; font-weight:bold; color:#6a0dad; direction: rtl;'>{labels[1]}</div>",
|
| 833 |
unsafe_allow_html=True)
|
| 834 |
|
| 835 |
-
# بهروزرسانی session_state بر اساس پیام
|
| 836 |
-
if "button_click_value" in st.session_state and st.session_state["button_click_value"] is not None:
|
| 837 |
-
st.session_state[key] = st.session_state["button_click_value"]
|
| 838 |
-
del st.session_state["button_click_value"]
|
| 839 |
-
|
| 840 |
# نمایش پاسخ انتخابشده
|
| 841 |
if st.session_state[key] != 0:
|
| 842 |
st.markdown(f"<p style='text-align:right; color:#6a0dad; direction: rtl;'>پاسخ شما: {st.session_state[key]}</p>",
|
|
@@ -856,7 +834,7 @@ def enhanced_likert_scale(question_data):
|
|
| 856 |
direction: rtl;
|
| 857 |
}
|
| 858 |
/* استایل خاص برای دکمههای لیکرت */
|
| 859 |
-
|
| 860 |
margin: 0 5px !important;
|
| 861 |
width: 30px !important;
|
| 862 |
height: 30px !important;
|
|
@@ -869,7 +847,7 @@ def enhanced_likert_scale(question_data):
|
|
| 869 |
color: #6a0dad !important;
|
| 870 |
cursor: pointer !important;
|
| 871 |
}
|
| 872 |
-
|
| 873 |
background-color: #6a0dad !important;
|
| 874 |
color: #fff !important;
|
| 875 |
}
|
|
@@ -878,7 +856,7 @@ def enhanced_likert_scale(question_data):
|
|
| 878 |
.likert-separator {
|
| 879 |
width: 90%;
|
| 880 |
}
|
| 881 |
-
[data-testid="stHorizontalBlock"]
|
| 882 |
margin: 0 2px !important;
|
| 883 |
}
|
| 884 |
}
|
|
@@ -895,6 +873,7 @@ def enhanced_likert_scale(question_data):
|
|
| 895 |
""", unsafe_allow_html=True)
|
| 896 |
|
| 897 |
return st.session_state.get(key)
|
|
|
|
| 898 |
def create_ride_map():
|
| 899 |
"""ایجاد نقشه سفر با Folium - نسخه اصلاح شده با مناطق عمومی"""
|
| 900 |
# نقاط تقریبی برای مناطق عمومی جنوب و غرب تهران
|
|
|
|
| 803 |
|
| 804 |
for i in range(scale):
|
| 805 |
with cols[i + 2]: # شروع از ستون دوم (پس از برچسبها)
|
| 806 |
+
button_key = f"{key}_btn_{i}"
|
| 807 |
+
is_selected = selected_value == int(options[i])
|
| 808 |
+
st.markdown(f'<div style="text-align: center;">', unsafe_allow_html=True)
|
| 809 |
+
if st.button(options[i], key=button_key, disabled=selected_value != 0 and not is_selected):
|
| 810 |
+
st.session_state[key] = int(options[i])
|
| 811 |
+
st.markdown(f'</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 812 |
|
| 813 |
# نمایش برچسب سمت چپ
|
| 814 |
with cols[1]:
|
| 815 |
st.markdown(f"<div style='text-align:left; font-size:14px; font-weight:bold; color:#6a0dad; direction: rtl;'>{labels[1]}</div>",
|
| 816 |
unsafe_allow_html=True)
|
| 817 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 818 |
# نمایش پاسخ انتخابشده
|
| 819 |
if st.session_state[key] != 0:
|
| 820 |
st.markdown(f"<p style='text-align:right; color:#6a0dad; direction: rtl;'>پاسخ شما: {st.session_state[key]}</p>",
|
|
|
|
| 834 |
direction: rtl;
|
| 835 |
}
|
| 836 |
/* استایل خاص برای دکمههای لیکرت */
|
| 837 |
+
[data-testid="stButton"] {
|
| 838 |
margin: 0 5px !important;
|
| 839 |
width: 30px !important;
|
| 840 |
height: 30px !important;
|
|
|
|
| 847 |
color: #6a0dad !important;
|
| 848 |
cursor: pointer !important;
|
| 849 |
}
|
| 850 |
+
[data-testid="stButton"]:disabled {
|
| 851 |
background-color: #6a0dad !important;
|
| 852 |
color: #fff !important;
|
| 853 |
}
|
|
|
|
| 856 |
.likert-separator {
|
| 857 |
width: 90%;
|
| 858 |
}
|
| 859 |
+
[data-testid="stHorizontalBlock"] [data-testid="stButton"] {
|
| 860 |
margin: 0 2px !important;
|
| 861 |
}
|
| 862 |
}
|
|
|
|
| 873 |
""", unsafe_allow_html=True)
|
| 874 |
|
| 875 |
return st.session_state.get(key)
|
| 876 |
+
|
| 877 |
def create_ride_map():
|
| 878 |
"""ایجاد نقشه سفر با Folium - نسخه اصلاح شده با مناطق عمومی"""
|
| 879 |
# نقاط تقریبی برای مناطق عمومی جنوب و غرب تهران
|