GSMEthesis commited on
Commit
99258e4
·
verified ·
1 Parent(s): 066c6cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -36
app.py CHANGED
@@ -783,33 +783,6 @@ def enhanced_likert_scale(question_data):
783
  st.markdown(f"<div style='text-align:right; font-weight:bold; margin-bottom:15px; direction: rtl;'>{question}</div>",
784
  unsafe_allow_html=True)
785
 
786
- # تنظیم لیبل وسط برای مقیاس‌های فرد
787
- middle_label = ""
788
- middle_label_text = "متوسط" # لیبل پیش‌فرض برای وسط
789
- if scale % 2 == 1: # اگر مقیاس فرد باشد
790
- middle_value = (scale // 2) + 1
791
- middle_label = f"""
792
- <div class='label-container middle-label' style='left: 50%; transform: translateX(-50%);'>
793
- <span>{middle_label_text}</span>
794
- </div>
795
- """
796
-
797
- # نمایش برچسب‌ها با خطوط ارتباطی
798
- st.markdown(
799
- f"""
800
- <div class='labels-container'>
801
- <div class='label-container left-label'>
802
- <span>{labels[0]}</span>
803
- </div>
804
- {middle_label}
805
- <div class='label-container right-label'>
806
- <span>{labels[1]}</span>
807
- </div>
808
- </div>
809
- """,
810
- unsafe_allow_html=True
811
- )
812
-
813
  # رادیو باتن اصلی (مخفی)
814
  selected_value = st.radio(
815
  "",
@@ -857,6 +830,16 @@ def enhanced_likert_scale(question_data):
857
  for i in range(scale)
858
  ])
859
 
 
 
 
 
 
 
 
 
 
 
860
  # ترکیب تمام بخش‌ها با استایل بهبود یافته
861
  components.html(
862
  f"""
@@ -870,7 +853,7 @@ def enhanced_likert_scale(question_data):
870
  margin: 0 auto;
871
  direction: rtl;
872
  position: relative;
873
- padding-top: 40px; /* فضای کافی برای خطوط و لیبل‌ها */
874
  }}
875
  .likert-option {{
876
  width: 36px;
@@ -909,25 +892,37 @@ def enhanced_likert_scale(question_data):
909
  justify-content: space-between;
910
  width: 100%;
911
  max-width: 475px;
912
- margin: 0 auto 10px;
913
- position: relative;
 
914
  direction: rtl;
915
  }}
916
  .label-container {{
917
- position: relative;
918
  font-size: 14px;
919
  font-weight: bold;
920
  color: #6a0dad;
921
  text-align: center;
922
  flex: 1;
 
923
  }}
924
  .label-container span {{
925
  display: inline-block;
926
- max-width: 150px; /* محدود کردن عرض لیبل‌ها برای جلوگیری از تداخل */
927
  white-space: nowrap;
928
  overflow: hidden;
929
  text-overflow: ellipsis;
930
  }}
 
 
 
 
 
 
 
 
 
 
 
931
  /* خطوط ارتباطی */
932
  .left-label::before {{
933
  content: '';
@@ -957,7 +952,7 @@ def enhanced_likert_scale(question_data):
957
  height: 25px;
958
  background-color: #6a0dad;
959
  }}
960
- /* تنظیم موقعیت خطوط برای گزینه‌های مقیاس */
961
  .likert-option:nth-child(1)::before {{
962
  content: '';
963
  position: absolute;
@@ -992,11 +987,22 @@ def enhanced_likert_scale(question_data):
992
  z-index: 0;
993
  }}
994
  </style>
995
- <div class="likert-container">
996
- {options_html}
 
 
 
 
 
 
 
 
 
 
 
997
  </div>
998
  """,
999
- height=110 # افزایش ارتفاع برای جا دادن خطوط و لیبل‌ها
1000
  )
1001
 
1002
  # نمایش وضعیت انتخاب با استایل بهبود یافته
 
783
  st.markdown(f"<div style='text-align:right; font-weight:bold; margin-bottom:15px; direction: rtl;'>{question}</div>",
784
  unsafe_allow_html=True)
785
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
786
  # رادیو باتن اصلی (مخفی)
787
  selected_value = st.radio(
788
  "",
 
830
  for i in range(scale)
831
  ])
832
 
833
+ # تنظیم لیبل وسط برای مقیاس‌های فرد
834
+ middle_label = ""
835
+ middle_label_text = "متوسط"
836
+ if scale % 2 == 1: # اگر مقیاس فرد باشد
837
+ middle_label = f"""
838
+ <div class='label-container middle-label'>
839
+ <span>{middle_label_text}</span>
840
+ </div>
841
+ """
842
+
843
  # ترکیب تمام بخش‌ها با استایل بهبود یافته
844
  components.html(
845
  f"""
 
853
  margin: 0 auto;
854
  direction: rtl;
855
  position: relative;
856
+ padding-top: 50px; /* فضای کافی برای خطوط و لیبل‌ها */
857
  }}
858
  .likert-option {{
859
  width: 36px;
 
892
  justify-content: space-between;
893
  width: 100%;
894
  max-width: 475px;
895
+ margin: 0 auto;
896
+ position: absolute;
897
+ top: 0;
898
  direction: rtl;
899
  }}
900
  .label-container {{
 
901
  font-size: 14px;
902
  font-weight: bold;
903
  color: #6a0dad;
904
  text-align: center;
905
  flex: 1;
906
+ position: relative;
907
  }}
908
  .label-container span {{
909
  display: inline-block;
910
+ max-width: 150px; /* محدود کردن عرض لیبل‌ها */
911
  white-space: nowrap;
912
  overflow: hidden;
913
  text-overflow: ellipsis;
914
  }}
915
+ .left-label {{
916
+ text-align: right;
917
+ }}
918
+ .right-label {{
919
+ text-align: left;
920
+ }}
921
+ .middle-label {{
922
+ position: absolute;
923
+ left: 50%;
924
+ transform: translateX(-50%);
925
+ }}
926
  /* خطوط ارتباطی */
927
  .left-label::before {{
928
  content: '';
 
952
  height: 25px;
953
  background-color: #6a0dad;
954
  }}
955
+ /* تنظیم خطوط برای گزینه‌های مقیاس */
956
  .likert-option:nth-child(1)::before {{
957
  content: '';
958
  position: absolute;
 
987
  z-index: 0;
988
  }}
989
  </style>
990
+ <div class='likert-wrapper'>
991
+ <div class='labels-container'>
992
+ <div class='label-container left-label'>
993
+ <span>{labels[0]}</span>
994
+ </div>
995
+ {middle_label}
996
+ <div class='label-container right-label'>
997
+ <span>{labels[1]}</span>
998
+ </div>
999
+ </div>
1000
+ <div class="likert-container">
1001
+ {options_html}
1002
+ </div>
1003
  </div>
1004
  """,
1005
+ height=120 # افزایش ارتفاع برای جا دادن لیبل‌ها و خطوط
1006
  )
1007
 
1008
  # نمایش وضعیت انتخاب با استایل بهبود یافته