Update app.py
Browse files
app.py
CHANGED
@@ -2652,7 +2652,7 @@ def show_sidebar():
|
|
2652 |
st.sidebar.info("ยังไม่มีเรื่องราวที่จะรีเซ็ต")
|
2653 |
|
2654 |
def show_story_input():
|
2655 |
-
"""Display story input section"""
|
2656 |
st.markdown("""
|
2657 |
<div class="thai-eng">
|
2658 |
<div class="thai">✏️ ถึงตาคุณแล้ว</div>
|
@@ -2689,8 +2689,9 @@ def show_story_input():
|
|
2689 |
# Save current input to session state
|
2690 |
st.session_state.text_input = text_input
|
2691 |
|
2692 |
-
# Submit
|
2693 |
-
col1, col2 = st.columns([3, 1])
|
|
|
2694 |
with col1:
|
2695 |
if st.button("📝 ส่งคำตอบ | Submit", use_container_width=True):
|
2696 |
if not text_input.strip():
|
@@ -2704,9 +2705,17 @@ def show_story_input():
|
|
2704 |
st.error("เกิดข้อผิดพลาดในการส่งคำตอบ กรุณาลองใหม่อีกครั้ง")
|
2705 |
|
2706 |
with col2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2707 |
char_count = len(text_input)
|
2708 |
st.markdown(f"""
|
2709 |
-
<div style="text-align: right; color: {'red' if char_count > 200 else '#666'};">
|
2710 |
{char_count}/200 ตัวอักษร
|
2711 |
</div>
|
2712 |
""", unsafe_allow_html=True)
|
|
|
2652 |
st.sidebar.info("ยังไม่มีเรื่องราวที่จะรีเซ็ต")
|
2653 |
|
2654 |
def show_story_input():
|
2655 |
+
"""Display story input section with clear button"""
|
2656 |
st.markdown("""
|
2657 |
<div class="thai-eng">
|
2658 |
<div class="thai">✏️ ถึงตาคุณแล้ว</div>
|
|
|
2689 |
# Save current input to session state
|
2690 |
st.session_state.text_input = text_input
|
2691 |
|
2692 |
+
# Submit and Clear buttons with character count
|
2693 |
+
col1, col2, col3 = st.columns([3, 1, 1])
|
2694 |
+
|
2695 |
with col1:
|
2696 |
if st.button("📝 ส่งคำตอบ | Submit", use_container_width=True):
|
2697 |
if not text_input.strip():
|
|
|
2705 |
st.error("เกิดข้อผิดพลาดในการส่งคำตอบ กรุณาลองใหม่อีกครั้ง")
|
2706 |
|
2707 |
with col2:
|
2708 |
+
# Add Clear button with space padding
|
2709 |
+
if st.button("🗑️ ล้างข้อความ | Clear", use_container_width=True):
|
2710 |
+
st.session_state.text_input = ""
|
2711 |
+
st.session_state.clear_input = True
|
2712 |
+
st.rerun()
|
2713 |
+
|
2714 |
+
with col3:
|
2715 |
+
# Character count
|
2716 |
char_count = len(text_input)
|
2717 |
st.markdown(f"""
|
2718 |
+
<div style="text-align: right; color: {'red' if char_count > 200 else '#666'}; padding: 8px;">
|
2719 |
{char_count}/200 ตัวอักษร
|
2720 |
</div>
|
2721 |
""", unsafe_allow_html=True)
|