ervau commited on
Commit
eb75910
·
1 Parent(s): 2643ed2

make multiselect box scrollable and discard view selected proteins container to only keep download button

Browse files
Files changed (1) hide show
  1. ProtHGT_app.py +28 -37
ProtHGT_app.py CHANGED
@@ -127,13 +127,24 @@ with st.sidebar:
127
  )
128
  filtered_proteins = [match[0] for match in matches] # Show top 50 matches
129
 
130
- selected_proteins = st.multiselect(
131
- "2\\. Select proteins from search results",
132
- options=filtered_proteins,
133
- placeholder="Start typing a protein ID above (1) to see search results...",
134
- max_selections=100,
135
- disabled=disabled
136
- )
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  else: # Upload file option
139
  uploaded_file = st.file_uploader(
@@ -189,36 +200,16 @@ with st.sidebar:
189
  """)
190
 
191
  if selected_proteins:
192
- with st.expander("View Selected Proteins"):
193
- st.write(f"Total proteins selected: {len(selected_proteins)}")
194
-
195
- # Create scrollable container with fixed height
196
- st.markdown(
197
- f"""
198
- <div style="
199
- height: 150px;
200
- overflow-y: scroll;
201
- border: 1px solid #ccc;
202
- border-radius: 4px;
203
- padding: 8px;
204
- background-color: white;">
205
- {'<br>'.join(selected_proteins)}
206
- </div>
207
- """,
208
- unsafe_allow_html=True
209
- )
210
-
211
- st.markdown("<div style='padding-top: 10px;'></div>", unsafe_allow_html=True)
212
-
213
- # Add download button
214
- proteins_text = '\n'.join(selected_proteins)
215
- st.download_button(
216
- label="Download List",
217
- data=proteins_text,
218
- file_name="selected_proteins.txt",
219
- mime="text/plain",
220
- key="download_button"
221
- )
222
 
223
  # Add GO category selection
224
  go_category_options = {
 
127
  )
128
  filtered_proteins = [match[0] for match in matches] # Show top 50 matches
129
 
130
+ with st.container():
131
+ selected_proteins = st.multiselect(
132
+ "2\\. Select proteins from search results",
133
+ options=filtered_proteins,
134
+ placeholder="Start typing a protein ID above (1) to see search results...",
135
+ max_selections=100,
136
+ disabled=disabled,
137
+ key="protein_selector"
138
+ )
139
+ # Apply custom CSS to make container scrollable
140
+ st.markdown("""
141
+ <style>
142
+ div[data-testid="stMultiSelect"] div:nth-child(2) {
143
+ max-height: 250px;
144
+ overflow-y: auto;
145
+ }
146
+ </style>
147
+ """, unsafe_allow_html=True)
148
 
149
  else: # Upload file option
150
  uploaded_file = st.file_uploader(
 
200
  """)
201
 
202
  if selected_proteins:
203
+ st.write(f"Total proteins selected: {len(selected_proteins)}")
204
+ # Add download button
205
+ proteins_text = '\n'.join(selected_proteins)
206
+ st.download_button(
207
+ label="Download Selected Proteins List",
208
+ data=proteins_text,
209
+ file_name="selected_proteins.txt",
210
+ mime="text/plain",
211
+ key="download_selected_proteins"
212
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
 
214
  # Add GO category selection
215
  go_category_options = {