Bläddra i källkod

feat: 更新数据展示组件宽度设置,支持自适应宽度

zhch158_admin 1 månad sedan
förälder
incheckning
e8a57aba1c
3 ändrade filer med 6 tillägg och 6 borttagningar
  1. 2 2
      streamlit_validator_cross.py
  2. 3 3
      streamlit_validator_result.py
  3. 1 1
      streamlit_validator_table.py

+ 2 - 2
streamlit_validator_cross.py

@@ -50,7 +50,7 @@ def cross_validation_dialog(validator):
                 help="选择文本相似度计算算法"
             )
     
-    if st.button("🚀 开始批量验证", type="primary", use_container_width=True):
+    if st.button("🚀 开始批量验证", type="primary", width='stretch'):
         run_batch_cross_validation(validator, table_mode, similarity_algorithm)
     
     if 'cross_validation_batch_result' in st.session_state and st.session_state.cross_validation_batch_result:
@@ -402,7 +402,7 @@ def display_batch_validation_results(batch_results: dict):
     # 显示表格
     st.dataframe(
         df_pages,
-        use_container_width=True,
+        width='stretch',
         hide_index=True,
         column_config={
             "页码": st.column_config.NumberColumn("页码", width="small"),

+ 3 - 3
streamlit_validator_result.py

@@ -210,7 +210,7 @@ def _display_differences_dataframe(comparison_result: dict):
         subset=['严重程度']
     ).format({'序号': '{:d}'})
     
-    st.dataframe(styled_df, use_container_width=True, height=400, hide_index=True)
+    st.dataframe(styled_df, width='stretch', height=400, hide_index=True)
 
 
 def _display_difference_details(comparison_result: dict):
@@ -268,7 +268,7 @@ def _display_difference_charts(comparison_result: dict):
                 names=list(type_counts.keys()),
                 title="差异类型分布"
             )
-            st.plotly_chart(fig_type, use_container_width=True)
+            st.plotly_chart(fig_type, width='stretch')
     
     with col2:
         fig_severity = px.bar(
@@ -278,7 +278,7 @@ def _display_difference_charts(comparison_result: dict):
             color=list(severity_counts.keys()),
             color_discrete_map={'高': '#f44336', '中': '#ff9800', '低': '#4caf50'}
         )
-        st.plotly_chart(fig_severity, use_container_width=True)
+        st.plotly_chart(fig_severity, width='stretch')
 
 
 def _provide_download_options(comparison_result: dict):

+ 1 - 1
streamlit_validator_table.py

@@ -205,7 +205,7 @@ def _render_table_with_style(filtered_table: pd.DataFrame, original_table: pd.Da
         st.markdown(f'<div class="{container_class}">', unsafe_allow_html=True)
         edited_table = st.data_editor(
             filtered_table, 
-            use_container_width=True, 
+            width='stretch', 
             key=f"editor_{table_index}",
             height=400 if len(original_table.columns) > 8 else None
         )