From c260504fc2ed3ee7d683bae2c770389095431683 Mon Sep 17 00:00:00 2001 From: puke <1129090915@qq.com> Date: Fri, 7 Nov 2025 14:45:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A8=A1=E6=9D=BF=E9=87=8D?= =?UTF-8?q?=E5=90=8D=E6=97=B6=E7=9A=84=E8=AF=86=E5=88=AB=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/app.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/web/app.py b/web/app.py index 79510c0..37bd8e6 100644 --- a/web/app.py +++ b/web/app.py @@ -666,7 +666,7 @@ def main(): } display_options = [] - template_path_map = {} + template_paths_ordered = [] # Use ordered list instead of dict to avoid key conflicts default_index = 0 current_index = 0 @@ -685,13 +685,14 @@ def main(): # Add group separator separator = f"─── {orientation} {width}×{height} ───" display_options.append(separator) + template_paths_ordered.append(None) # Separator has no template path current_index += 1 # Add templates in this group for t in templates: display_name = f" {t.display_info.name}" display_options.append(display_name) - template_path_map[display_name] = t.template_path + template_paths_ordered.append(t.template_path) # Add to ordered list # Set default to first "default.html" in portrait orientation if default_index == 0 and "default.html" in t.display_info.name and t.display_info.orientation == 'portrait': @@ -700,21 +701,32 @@ def main(): current_index += 1 # Dropdown with grouped display - selected_display_name = st.selectbox( + # Create unique display strings by appending hidden unique identifier + # This ensures Streamlit doesn't confuse templates with same name in different groups + unique_display_options = [] + for i, option in enumerate(display_options): + # Add zero-width space characters as unique identifier (invisible to users) + unique_option = option + ("\u200B" * i) # \u200B is zero-width space + unique_display_options.append(unique_option) + + selected_unique_option = st.selectbox( tr("template.select"), - display_options, + unique_display_options, index=default_index, label_visibility="collapsed", help=tr("template.select_help") ) + # Get index from selected unique option + selected_index = unique_display_options.index(selected_unique_option) + # Check if separator is selected (shouldn't happen, but handle it) - if selected_display_name.startswith("───"): + if display_options[selected_index].startswith("───"): st.warning(tr("template.separator_selected")) st.stop() - # Get full template path - frame_template = template_path_map.get(selected_display_name) + # Get full template path directly by index + frame_template = template_paths_ordered[selected_index] # Display video size from template from pixelle_video.utils.template_util import parse_template_size