uiutils

Back to the docs main page

textui.uiutils.print_in_columns(entries, buffer_chars=4, fixed_width_columns=False, column_major=True)[source]

Given a list of entries, print them in columns across the terminal

This function will try to evenly divide the given list of entries into columns across the current terminal. By default, it will left-align each column and put at least 4 spaces between each column. Successive entries will be printed in columns by default.

Parameters:
  • entries (list of str) – the list of entries to print, as strings
  • buffer_chars – optional, the minimum number of spaces required between columns, i.e. the number of spaces that will follow the longest entry in that column. Default is 4.
  • fixed_width_columns (bool) – optional, controls whether all columns have the same width (True) or different widths as long as the number of buffer_chars is maintained (False). Default is False.
  • column_major (bool) – optional, controls whether successive elements are printed along columns (True) or rows (False). Default is True.
Returns:

None