GSMEthesis commited on
Commit
3b44fe1
·
verified ·
1 Parent(s): 1f11c4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -23
app.py CHANGED
@@ -790,35 +790,26 @@ def enhanced_likert_scale(question_data):
790
 
791
  # تنظیم چیدمان مرکزی با ستون‌ها
792
  total_cols = scale + 2 # یک ستون برای هر نقطه + 2 ستون برای برچسب‌ها
793
- col_widths = [1] + [2] * scale + [1] # برچسب‌ها باریک‌تر، نقاط پهن‌تر برای مرکزیت
794
- col_label1, *option_cols, col_label2 = st.columns(col_widths)
795
 
796
  # نمایش برچسب سمت راست
797
- with col_label1:
798
- st.markdown(f"<span style='font-size:14px; font-weight:bold; color:#6a0dad; direction: rtl;'>{labels[0]}</span>",
799
  unsafe_allow_html=True)
800
 
801
  # نمایش دکمه‌های رادیویی به صورت افقی و مرکزی
802
- with st.container():
803
- options = [str(i) for i in range(1, scale + 1)]
804
- selected_value = st.session_state.get(key, 0)
805
-
806
- for i, col in enumerate(option_cols, 1):
807
- with col:
808
- is_selected = selected_value == i
809
- st.radio(
810
- "",
811
- [str(i)],
812
- index=0 if is_selected else None,
813
- key=f"{key}_radio_{i}",
814
- label_visibility="collapsed",
815
- horizontal=True,
816
- on_change=lambda x=i: st.session_state.update({key: x})
817
- )
818
 
819
  # نمایش برچسب سمت چپ
820
- with col_label2:
821
- st.markdown(f"<span style='font-size:14px; font-weight:bold; color:#6a0dad; direction: rtl;'>{labels[1]}</span>",
822
  unsafe_allow_html=True)
823
 
824
  # نمایش پاسخ انتخاب‌شده
@@ -839,7 +830,6 @@ def enhanced_likert_scale(question_data):
839
  margin: 20px auto;
840
  direction: rtl;
841
  }
842
- /* اطمینان از مرکزیت در تمام دستگاه‌ها */
843
  @media (max-width: 768px) {
844
  .likert-separator {
845
  width: 90%;
 
790
 
791
  # تنظیم چیدمان مرکزی با ستون‌ها
792
  total_cols = scale + 2 # یک ستون برای هر نقطه + 2 ستون برای برچسب‌ها
793
+ col_widths = [1] * 2 + [2] * scale # 2 ستون برای برچسب‌ها ر کدام 1) و نقاط (هر کدام 2)
794
+ cols = st.columns(col_widths)
795
 
796
  # نمایش برچسب سمت راست
797
+ with cols[0]:
798
+ st.markdown(f"<div style='text-align:right; font-size:14px; font-weight:bold; color:#6a0dad; direction: rtl;'>{labels[0]}</div>",
799
  unsafe_allow_html=True)
800
 
801
  # نمایش دکمه‌های رادیویی به صورت افقی و مرکزی
802
+ options = [str(i) for i in range(1, scale + 1)]
803
+ selected_value = st.session_state.get(key, 0)
804
+
805
+ for i in range(scale):
806
+ with cols[i + 2]: # شروع از ستون دوم (پس از برچسب‌ها)
807
+ if st.button(options[i], key=f"{key}_btn_{i}", disabled=selected_value != 0 and selected_value != int(options[i])):
808
+ st.session_state[key] = int(options[i])
 
 
 
 
 
 
 
 
 
809
 
810
  # نمایش برچسب سمت چپ
811
+ with cols[1]:
812
+ st.markdown(f"<div style='text-align:left; font-size:14px; font-weight:bold; color:#6a0dad; direction: rtl;'>{labels[1]}</div>",
813
  unsafe_allow_html=True)
814
 
815
  # نمایش پاسخ انتخاب‌شده
 
830
  margin: 20px auto;
831
  direction: rtl;
832
  }
 
833
  @media (max-width: 768px) {
834
  .likert-separator {
835
  width: 90%;