-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
- I've checked docs and closed issues for possible solutions.
- I can't find my issue in the FAQ.
Describe the bug
The Panel object has an optional argument expand. When this is True (the default), the panel takes up the entire terminal width. When set to False, the panel shrinks to the width of the content inside the panel. This works most of the time, but fails when the Panel contains a Columns object. In this case, the Panel takes the whole terminal width with excess space on the right, even if expand=False is used.
A simple example that reproduces the issuse:
import rich
from rich.columns import Columns
from rich.panel import Panel
columns = Columns(['c1', 'c2'])
rich.print(Panel(columns, expand=False))
rich.print(Panel('this has expand=True', expand=True))
rich.print(Panel('this has expand=False', expand=False))
I've included two extra lines to show how it should work normally. Here is a screenshot of the output of the above program.
Platform
Click to expand
What platform (Win/Linux/Mac) are you running on? What terminal software are you using?
macOS Sequoia 15.6
I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.
If you're using Rich in a terminal:
python -m rich.diagnose
pip freeze | grep rich
❯ python -m rich.diagnose
╭─────────────────── <class 'rich.console.Console'> ───────────────────╮
│ A high level console interface. │
│ │
│ ╭──────────────────────────────────────────────────────────────────╮ │
│ │ <console width=72 ColorSystem.TRUECOLOR> │ │
│ ╰──────────────────────────────────────────────────────────────────╯ │
│ │
│ color_system = 'truecolor' │
│ encoding = 'utf-8' │
│ file = <_io.TextIOWrapper name='<stdout>' mode='w' │
│ encoding='utf-8'> │
│ height = 76 │
│ 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=72, height=76), │
│ legacy_windows=False, │
│ min_width=1, │
│ max_width=72, │
│ is_terminal=True, │
│ encoding='utf-8', │
│ max_height=76, │
│ justify=None, │
│ overflow=None, │
│ no_wrap=False, │
│ highlight=None, │
│ markup=None, │
│ height=None │
│ ) │
│ quiet = False │
│ record = False │
│ safe_box = True │
│ size = ConsoleDimensions(width=72, height=76) │
│ soft_wrap = False │
│ stderr = False │
│ style = None │
│ tab_size = 8 │
│ width = 72 │
╰──────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available. │
│ │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│ │
│ truecolor = False │
│ vt = False │
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ { │
│ 'CLICOLOR': None, │
│ 'COLORTERM': 'truecolor', │
│ 'COLUMNS': '72', │
│ 'JPY_PARENT_PID': None, │
│ 'JUPYTER_COLUMNS': None, │
│ 'JUPYTER_LINES': None, │
│ 'LINES': '76', │
│ 'NO_COLOR': None, │
│ 'TERM_PROGRAM': 'iTerm.app', │
│ 'TERM': 'xterm-256color', │
│ 'TTY_COMPATIBLE': None, │
│ 'TTY_INTERACTIVE': None, │
│ 'VSCODE_VERBOSE_LOGGING': None │
│ } │
╰────────────────────────────────────╯
platform="Darwin"
rich==14.1.0
If you're using Rich in a Jupyter Notebook, run the following snippet in a cell
and paste the output in your bug report.
from rich.diagnose import report
report()