Maryam Ilka commited on
Commit
febbc50
·
verified ·
1 Parent(s): c25bba9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -15
app.py CHANGED
@@ -581,11 +581,12 @@ def map_view():
581
  st.rerun()
582
 
583
  def attention_check1():
584
- """سوال توجه اول (بدون بررسی پاسخ صحیح)"""
 
585
  st.markdown("""
586
  <style>
587
- /* استایل دکمه سبز اختصاصی */
588
- .green-btn {
589
  background-color: #28a745 !important;
590
  color: white !important;
591
  border: none !important;
@@ -594,13 +595,19 @@ def attention_check1():
594
  font-weight: bold !important;
595
  width: 100% !important;
596
  margin-top: 15px !important;
 
597
  }
598
- .green-btn:hover {
599
  background-color: #218838 !important;
600
  }
 
 
 
 
 
601
  </style>
602
  """, unsafe_allow_html=True)
603
-
604
  st.markdown("### سوال توجه")
605
 
606
  answer = st.radio(
@@ -610,16 +617,22 @@ def attention_check1():
610
  key="att1_radio"
611
  )
612
 
613
- # دکمه سبز اختصاصی
614
- if st.button("ادامه", key="att1_btn"):
615
- st.markdown("""
616
- <style>
617
- div[data-testid="stButton"] > button[kind="primary"] {
618
- background-color: #28a745 !important;
619
- }
620
- </style>
621
- """, unsafe_allow_html=True)
622
-
 
 
 
 
 
 
623
  if answer:
624
  st.session_state.attention_check1 = answer
625
  st.session_state.current_page = "random_likert_questions"
 
581
  st.rerun()
582
 
583
  def attention_check1():
584
+ """سوال توجه اول با دکمه سبز کاملاً عملی"""
585
+ # 1. تزریق استایل‌های سفارشی
586
  st.markdown("""
587
  <style>
588
+ /* دکمه سبز اختصاصی */
589
+ .custom-green-btn {
590
  background-color: #28a745 !important;
591
  color: white !important;
592
  border: none !important;
 
595
  font-weight: bold !important;
596
  width: 100% !important;
597
  margin-top: 15px !important;
598
+ cursor: pointer !important;
599
  }
600
+ .custom-green-btn:hover {
601
  background-color: #218838 !important;
602
  }
603
+
604
+ /* مخفی کردن دکمه پیشفرض Streamlit */
605
+ div[data-testid="stButton"] > button[kind="primary"] {
606
+ display: none !important;
607
+ }
608
  </style>
609
  """, unsafe_allow_html=True)
610
+
611
  st.markdown("### سوال توجه")
612
 
613
  answer = st.radio(
 
617
  key="att1_radio"
618
  )
619
 
620
+ # 2. ایجاد دکمه سبز با JavaScript
621
+ st.components.v1.html(f"""
622
+ <script>
623
+ function handleClick() {{
624
+ // فعال کردن دکمه مخفی Streamlit
625
+ parent.document.querySelector('div[data-testid="stButton"] > button[kind="primary"]').click();
626
+ }}
627
+ </script>
628
+
629
+ <button onclick="handleClick()" class="custom-green-btn">
630
+ ادامه
631
+ </button>
632
+ """, height=60)
633
+
634
+ # 3. منطق اصلی دکمه (مخفی)
635
+ if st.button("ادامه", key="att1_real_btn", type="primary"):
636
  if answer:
637
  st.session_state.attention_check1 = answer
638
  st.session_state.current_page = "random_likert_questions"