Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -739,7 +739,7 @@ h3 {
|
|
| 739 |
|
| 740 |
# ========== توابع اصلی ==========
|
| 741 |
def enhanced_likert_scale(question_data):
|
| 742 |
-
"""لیکرت اسکیل
|
| 743 |
question = question_data["question"]
|
| 744 |
key = question_data["key"]
|
| 745 |
scale = question_data["scale"]
|
|
@@ -749,7 +749,7 @@ def enhanced_likert_scale(question_data):
|
|
| 749 |
if key not in st.session_state:
|
| 750 |
st.session_state[key] = None
|
| 751 |
|
| 752 |
-
# استایلدهی سفارشی برای دکمههای
|
| 753 |
st.markdown(
|
| 754 |
f"""
|
| 755 |
<style>
|
|
@@ -775,7 +775,7 @@ def enhanced_likert_scale(question_data):
|
|
| 775 |
color: #666666 !important;
|
| 776 |
}}
|
| 777 |
/* استایل ردیف دکمهها */
|
| 778 |
-
.
|
| 779 |
display: flex !important;
|
| 780 |
justify-content: center !important;
|
| 781 |
gap: 4px !important;
|
|
@@ -784,8 +784,8 @@ def enhanced_likert_scale(question_data):
|
|
| 784 |
padding: 0 !important;
|
| 785 |
align-items: center !important;
|
| 786 |
}}
|
| 787 |
-
/* استایل دکمههای
|
| 788 |
-
div
|
| 789 |
width: 20px !important;
|
| 790 |
height: 20px !important;
|
| 791 |
border-radius: 50% !important;
|
|
@@ -798,26 +798,23 @@ def enhanced_likert_scale(question_data):
|
|
| 798 |
box-shadow: none !important;
|
| 799 |
outline: none !important;
|
| 800 |
line-height: 1 !important;
|
|
|
|
|
|
|
|
|
|
| 801 |
}}
|
| 802 |
-
div
|
| 803 |
background: #e0e0e0 !important;
|
| 804 |
}}
|
| 805 |
-
div[data-
|
| 806 |
-
div[data-testid="stButton"] > button[key^="streamlit-btn-{key}-"]:active {{
|
| 807 |
-
background: black !important;
|
| 808 |
-
color: white !important;
|
| 809 |
-
}}
|
| 810 |
-
/* استایل دکمه انتخابشده */
|
| 811 |
-
div[data-testid="stButton"] > button[key="streamlit-btn-{key}-{st.session_state[key] if st.session_state[key] else 'none'}"] {{
|
| 812 |
background: black !important;
|
| 813 |
color: white !important;
|
| 814 |
}}
|
| 815 |
/* ریسپانسیو کردن */
|
| 816 |
@media (max-width: 600px) {{
|
| 817 |
-
.
|
| 818 |
gap: 2px !important;
|
| 819 |
}}
|
| 820 |
-
div
|
| 821 |
width: 18px !important;
|
| 822 |
height: 18px !important;
|
| 823 |
font-size: 12px !important;
|
|
@@ -827,12 +824,11 @@ def enhanced_likert_scale(question_data):
|
|
| 827 |
}}
|
| 828 |
}}
|
| 829 |
/* حذف استایلهای پیشفرض Streamlit */
|
| 830 |
-
div
|
| 831 |
border: none !important;
|
| 832 |
box-shadow: none !important;
|
| 833 |
outline: none !important;
|
| 834 |
background: transparent !important;
|
| 835 |
-
border-radius: 50% !important;
|
| 836 |
}}
|
| 837 |
</style>
|
| 838 |
""",
|
|
@@ -842,24 +838,23 @@ def enhanced_likert_scale(question_data):
|
|
| 842 |
# نمایش سوال
|
| 843 |
st.markdown(f'<div class="likert-container"><div class="likert-question">{question}</div>', unsafe_allow_html=True)
|
| 844 |
|
| 845 |
-
# نمایش لیبلها
|
| 846 |
st.markdown('<div class="likert-labels">', unsafe_allow_html=True)
|
| 847 |
st.markdown(f'<span style="text-align:right">{labels[0]}</span>', unsafe_allow_html=True)
|
| 848 |
|
| 849 |
-
# دکمهها
|
| 850 |
-
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
st.rerun()
|
| 863 |
|
| 864 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 865 |
st.markdown(f'<span style="text-align:left">{labels[1]}</span>', unsafe_allow_html=True)
|
|
@@ -874,6 +869,7 @@ def enhanced_likert_scale(question_data):
|
|
| 874 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 875 |
|
| 876 |
return st.session_state.get(key)
|
|
|
|
| 877 |
|
| 878 |
def create_ride_map():
|
| 879 |
"""ایجاد نقشه سفر با Folium - نسخه اصلاح شده با مناطق عمومی"""
|
|
|
|
| 739 |
|
| 740 |
# ========== توابع اصلی ==========
|
| 741 |
def enhanced_likert_scale(question_data):
|
| 742 |
+
"""لیکرت اسکیل با st.radio و دکمههای دایرهای تو یه ردیف"""
|
| 743 |
question = question_data["question"]
|
| 744 |
key = question_data["key"]
|
| 745 |
scale = question_data["scale"]
|
|
|
|
| 749 |
if key not in st.session_state:
|
| 750 |
st.session_state[key] = None
|
| 751 |
|
| 752 |
+
# استایلدهی سفارشی برای دکمههای radio
|
| 753 |
st.markdown(
|
| 754 |
f"""
|
| 755 |
<style>
|
|
|
|
| 775 |
color: #666666 !important;
|
| 776 |
}}
|
| 777 |
/* استایل ردیف دکمهها */
|
| 778 |
+
.stRadio > div {{
|
| 779 |
display: flex !important;
|
| 780 |
justify-content: center !important;
|
| 781 |
gap: 4px !important;
|
|
|
|
| 784 |
padding: 0 !important;
|
| 785 |
align-items: center !important;
|
| 786 |
}}
|
| 787 |
+
/* استایل دکمههای radio */
|
| 788 |
+
.stRadio > div > label > div > div > div {{
|
| 789 |
width: 20px !important;
|
| 790 |
height: 20px !important;
|
| 791 |
border-radius: 50% !important;
|
|
|
|
| 798 |
box-shadow: none !important;
|
| 799 |
outline: none !important;
|
| 800 |
line-height: 1 !important;
|
| 801 |
+
display: flex !important;
|
| 802 |
+
align-items: center !important;
|
| 803 |
+
justify-content: center !important;
|
| 804 |
}}
|
| 805 |
+
.stRadio > div > label > div > div > div:hover {{
|
| 806 |
background: #e0e0e0 !important;
|
| 807 |
}}
|
| 808 |
+
.stRadio > div > label > div > div > div[data-baseweb="radio"] input:checked ~ div {{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 809 |
background: black !important;
|
| 810 |
color: white !important;
|
| 811 |
}}
|
| 812 |
/* ریسپانسیو کردن */
|
| 813 |
@media (max-width: 600px) {{
|
| 814 |
+
.stRadio > div {{
|
| 815 |
gap: 2px !important;
|
| 816 |
}}
|
| 817 |
+
.stRadio > div > label > div > div > div {{
|
| 818 |
width: 18px !important;
|
| 819 |
height: 18px !important;
|
| 820 |
font-size: 12px !important;
|
|
|
|
| 824 |
}}
|
| 825 |
}}
|
| 826 |
/* حذف استایلهای پیشفرض Streamlit */
|
| 827 |
+
.stRadio > div > label > div > div > div {{
|
| 828 |
border: none !important;
|
| 829 |
box-shadow: none !important;
|
| 830 |
outline: none !important;
|
| 831 |
background: transparent !important;
|
|
|
|
| 832 |
}}
|
| 833 |
</style>
|
| 834 |
""",
|
|
|
|
| 838 |
# نمایش سوال
|
| 839 |
st.markdown(f'<div class="likert-container"><div class="likert-question">{question}</div>', unsafe_allow_html=True)
|
| 840 |
|
| 841 |
+
# نمایش لیبلها
|
| 842 |
st.markdown('<div class="likert-labels">', unsafe_allow_html=True)
|
| 843 |
st.markdown(f'<span style="text-align:right">{labels[0]}</span>', unsafe_allow_html=True)
|
| 844 |
|
| 845 |
+
# دکمهها با st.radio
|
| 846 |
+
options = [str(i) for i in range(1, scale + 1)]
|
| 847 |
+
symbols = ["○"] * scale
|
| 848 |
+
selected_index = options.index(str(st.session_state.get(key, 1))) if st.session_state.get(key) else 0
|
| 849 |
+
value = st.radio(
|
| 850 |
+
"",
|
| 851 |
+
options=options,
|
| 852 |
+
format_func=lambda x: "•" if options.index(x) == selected_index else "○",
|
| 853 |
+
key=f"radio-{key}",
|
| 854 |
+
index=selected_index,
|
| 855 |
+
horizontal=True
|
| 856 |
+
)
|
| 857 |
+
st.session_state[key] = int(value)
|
|
|
|
| 858 |
|
| 859 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 860 |
st.markdown(f'<span style="text-align:left">{labels[1]}</span>', unsafe_allow_html=True)
|
|
|
|
| 869 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 870 |
|
| 871 |
return st.session_state.get(key)
|
| 872 |
+
|
| 873 |
|
| 874 |
def create_ride_map():
|
| 875 |
"""ایجاد نقشه سفر با Folium - نسخه اصلاح شده با مناطق عمومی"""
|