From 6fda6aea6b1e7ab072b36f2c31c7e5b9bd61bfe8 Mon Sep 17 00:00:00 2001 From: trnq1ll0 Date: Wed, 10 Jun 2026 17:16:43 +0200 Subject: [PATCH] automatisch selektieren wenn in Input- oder Template-Ordner nur ein Element/File liegt --- app.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/app.py b/app.py index 92e000c..a19f40e 100644 --- a/app.py +++ b/app.py @@ -76,11 +76,18 @@ with col1: st.warning("Keine .xlsx-Dateien im input/-Ordner gefunden.") selected_input = None else: - selected_input = st.selectbox( - "Input-Datei wählen:", - options=[""] + input_files, - format_func=lambda x: "– Bitte wählen –" if x == "" else x, - ) + # Bei nur einer Datei: automatisch selektieren (keine Leerauswahl) + if len(input_files) == 1: + selected_input = st.selectbox( + "Input-Datei wählen:", + options=input_files, + ) + else: + selected_input = st.selectbox( + "Input-Datei wählen:", + options=[""] + input_files, + format_func=lambda x: "– Bitte wählen –" if x == "" else x, + ) if selected_input: input_path = Path(app_config.input_dir) / selected_input @@ -157,11 +164,18 @@ with col2: real_templates = [t for t in template_files if not t.startswith("~")] if not real_templates: real_templates = template_files - selected_template = st.selectbox( - "Template wählen:", - options=[""] + real_templates, - format_func=lambda x: "– Bitte wählen –" if x == "" else x, - ) + # Bei nur einem Template: automatisch selektieren (keine Leerauswahl) + if len(real_templates) == 1: + selected_template = st.selectbox( + "Template wählen:", + options=real_templates, + ) + else: + selected_template = st.selectbox( + "Template wählen:", + options=[""] + real_templates, + format_func=lambda x: "– Bitte wählen –" if x == "" else x, + ) if selected_template: # Nur validieren wenn sich das Template geändert hat