Spaces in selectbox and text

I want to display additional pieces of information in a selectbox, because the information is organized by field I wish to align the fields, as a result, I am using a format_func like:

def display_fancy_label(_x):
_log_list = find_filetype_in_dir(_dir_name=_result_path+_x, _file_type=‘log’)
_png_list = find_filetype_in_dir(_dir_name=_result_path+_x, _file_type=‘png’)
_pth_list = find_filetype_in_dir(_dir_name=_result_path+_x, _file_type=‘pth’)
return ‘{:>100} log({:02d}) png({:02d}) pth({:02d})’.format(_x, len(_log_list), len(_pth_list), len(_png_list))

However, be it in selectbox or even in text, all duplicated spaces are striped, e.g.:

ex_1 = ’ '*6+‘1’

Now, for text specifically, it comes from the use of _clean_text line 2618 of, removing it lead to the correct display. However, I cannot yet find where a similar stripping had been done for the display of options in selectbox. I welcome any solution to make the display ex_1 works correctly as an option in a selectbox. Also, I wonder why the choice had been made to strip spaces by default.

Hi @RR5555,

Looks like the stripping of whitespace in the Selectbox is being done by Baseweb, not by Streamlit.

You can reproduce this via their code sandbox. Change one of the options to include additional whitespace and scroll back up to the component and you’ll see the same behavior.

I wasn’t able to find exactly where in their Select component it’s being done. Perhaps you can spot it?