Skip to content

Commit 9674791

Browse files
authored
Merge pull request #322 from OpenMS/claude/streamlit-multiselect-ui-d7bm5
Improve list parameter UX with multiselect for valid options
2 parents a0b3f7e + e5d9480 commit 9674791

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/workflow/StreamlitUI.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -864,19 +864,26 @@ def display_TOPP_params(params: dict, num_cols):
864864
v.decode() if isinstance(v, bytes) else v
865865
for v in p["value"]
866866
]
867-
valid_entries_info = ''
867+
868+
# Use multiselect when valid_strings are available for better UX
868869
if len(p['valid_strings']) > 0:
869-
valid_entries_info = (
870-
" Valid entries are: "
871-
+ ', '.join(sorted(p['valid_strings']))
870+
# Filter current values to only include valid options
871+
current_values = [v for v in p["value"] if v in p['valid_strings']]
872+
cols[i].multiselect(
873+
name,
874+
options=sorted(p['valid_strings']),
875+
default=current_values,
876+
help=p["description"],
877+
key=key,
878+
)
879+
else:
880+
# Fall back to text_area for freeform list input
881+
cols[i].text_area(
882+
name,
883+
value="\n".join([str(val) for val in p["value"]]),
884+
help=p["description"] + " Separate entries using the \"Enter\" key.",
885+
key=key,
872886
)
873-
874-
cols[i].text_area(
875-
name,
876-
value="\n".join([str(val) for val in p["value"]]),
877-
help=p["description"] + " Separate entries using the \"Enter\" key." + valid_entries_info,
878-
key=key,
879-
)
880887

881888
# increment number of columns, create new cols object if end of line is reached
882889
i += 1

0 commit comments

Comments
 (0)