rich
rich copied to clipboard
[BUG] Rich is not using the full width of the Jupyter notebook
Rich is not using the full width of the Jupyter notebook.
For example, here I expect the lines for index
and sort
to be both fit on one line.
I am not sure if this is the same issue as this. If it is, is there a way I can manually set the width (I'd do it at the beginning of the notebook)? Thanks!
It works fine on IPython in the terminal though.
Platform
Click to expand
What platform (Win/Linux/Mac) are you running on? What terminal software are you using?
Mac; Jupyter
I may ask you to cut and paste the output of the following commands. It may save some time if you do it now.
python -m rich.diagnose
python -m rich._windows
pip freeze | grep rich
╭─────────────────────── <class 'rich.console.Console'> ───────────────────────╮
│ A high level console interface. │
│ │
│ ╭──────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=80 ColorSystem.TRUECOLOR> │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│ │
│ color_system = 'truecolor' │
│ encoding = 'utf-8' │
│ file = <_io.TextIOWrapper name='<stdout>' mode='w' │
│ encoding='utf-8'> │
│ height = 24 │
│ is_alt_screen = False │
│ is_dumb_terminal = False │
│ is_interactive = True │
│ is_jupyter = False │
│ is_terminal = True │
│ legacy_windows = False │
│ no_color = False │
│ options = ConsoleOptions( │
│ size=ConsoleDimensions(width=80, height=24), │
│ legacy_windows=False, │
│ min_width=1, │
│ max_width=80, │
│ is_terminal=True, │
│ encoding='utf-8', │
│ max_height=24, │
│ justify=None, │
│ overflow=None, │
│ no_wrap=False, │
│ highlight=None, │
│ markup=None, │
│ height=None │
│ ) │
│ quiet = False │
│ record = False │
│ safe_box = True │
│ size = ConsoleDimensions(width=80, height=24) │
│ soft_wrap = False │
│ stderr = False │
│ style = None │
│ tab_size = 8 │
│ width = 80 │
╰──────────────────────────────────────────────────────────────────────────────╯
platform="Darwin"
WindowsConsoleFeatures(vt=False, truecolor=False)
rich @ file:///home/conda/feedstock_root/build_artifacts/rich_1641736075057/work
You will likely get a better answer from Will but, in the meantime, you can try the following:
import rich
con = rich.get_console()
con.width = 160 # as an example
rich.inspect([1, 2], methods=True)
Thank you @aroberge . This works for me. The only issue is that getting the width of the Jupyter window requires a few lines of code and I'd prefer it to be automatic since I am lazy :-)
I'd be interested to see what Will might propose too.