automatisch selektieren wenn in Input- oder Template-Ordner nur ein Element/File liegt

This commit is contained in:
trnq1ll0 committed 2026-06-10 17:16:43 +02:00
1 parent 9a44f8904e
commit 6fda6aea6b
1 file changed
+24 -10
+24 -10
View File
@@ -76,11 +76,18 @@ with col1:
st.warning("Keine .xlsx-Dateien im input/-Ordner gefunden.") st.warning("Keine .xlsx-Dateien im input/-Ordner gefunden.")
selected_input = None selected_input = None
else: else:
selected_input = st.selectbox( # Bei nur einer Datei: automatisch selektieren (keine Leerauswahl)
"Input-Datei wählen:", if len(input_files) == 1:
options=[""] + input_files, selected_input = st.selectbox(
format_func=lambda x: "– Bitte wählen –" if x == "" else x, "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: if selected_input:
input_path = Path(app_config.input_dir) / 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("~")] real_templates = [t for t in template_files if not t.startswith("~")]
if not real_templates: if not real_templates:
real_templates = template_files real_templates = template_files
selected_template = st.selectbox( # Bei nur einem Template: automatisch selektieren (keine Leerauswahl)
"Template wählen:", if len(real_templates) == 1:
options=[""] + real_templates, selected_template = st.selectbox(
format_func=lambda x: "– Bitte wählen –" if x == "" else x, "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: if selected_template:
# Nur validieren wenn sich das Template geändert hat # Nur validieren wenn sich das Template geändert hat