Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Panel inside Layout being cut off #3117

Closed
2 tasks done
gary-conlon opened this issue Sep 1, 2023 · 9 comments
Closed
2 tasks done

[BUG] Panel inside Layout being cut off #3117

gary-conlon opened this issue Sep 1, 2023 · 9 comments

Comments

@gary-conlon
Copy link

Describe the bug

When rendering a panel inside a layout the content of the panel is cut short. The bottom border of the panel is still drawen.

When printing the panel itself everything appears good.

Note below render group can be replaced with a big string that would take up a lot of the terminal

render_group = Group(
                     "[bold underline]Description[/]\n",
                     description_markdown,
                     "\n[bold underline]Acceptance Criteria[/]\n",
                     acceptance_criteria_markdown,
                     "\n[bold underline]Release Notes[/]\n",
                     release_notes_markdown)

left_panel = Panel(render_group, width=80)

layout = Layout()

layout.update(left_panel)

console.print(layout)

Platform

Mac, Warp terminal, Pycharm terminal

I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.

───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=174 ColorSystem.TRUECOLOR>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = 'truecolor'                                                   │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 47                                                            │
│    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=174, height=47),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=174,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=47,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=174, height=47)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 174                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯
╭─────── Environment Variables ───────╮
│ {                                   │
│     'TERM': 'xterm-256color',       │
│     'COLORTERM': 'truecolor',       │
│     'CLICOLOR': None,               │
│     'NO_COLOR': None,               │
│     'TERM_PROGRAM': 'WarpTerminal', │
│     'COLUMNS': None,                │
│     'LINES': None,                  │
│     'JUPYTER_COLUMNS': None,        │
│     'JUPYTER_LINES': None,          │
│     'JPY_PARENT_PID': None,         │
│     'VSCODE_VERBOSE_LOGGING': None  │
│ }                                   │
╰─────────────────────────────────────╯
platform="Darwin"

rich==13.4.2
@github-actions
Copy link

github-actions bot commented Sep 1, 2023

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@willmcgugan
Copy link
Collaborator

willmcgugan commented Sep 1, 2023

I'll need code to reproduce the issue before I can help you. Screenshots would also help.

https://label.dev/articles/minimal-reproducible-example/

@gary-conlon
Copy link
Author

gary-conlon commented Sep 1, 2023

Hi sorry, here is the mre

from rich.console import Console
from rich.panel import Panel
from rich.layout import Layout
console = Console()

big_text = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras egestas nibh sem, eu auctor felis ultrices vel. Nulla blandit sed neque sit amet varius. Cras pretium enim nisl, nec vehicula erat dignissim at. Etiam elementum ligula arcu. Pellentesque feugiat orci vel semper vulputate. Cras nec cursus leo. Pellentesque dui felis, vulputate sed facilisis eu, varius ac metus. Praesent accumsan libero ex, sit amet vestibulum turpis euismod id.

Nunc congue dapibus mauris id laoreet. Maecenas tempor quam eget efficitur tristique. Donec vestibulum luctus libero non pellentesque. Ut sagittis commodo purus. Nam sit amet magna vitae purus consectetur laoreet. Integer at ligula velit. Ut sed ultrices nisi. Ut nec enim quis turpis hendrerit consequat.

Nam tellus risus, molestie id tristique vel, aliquet id nisi. Praesent efficitur libero eu nibh porttitor pharetra. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean egestas arcu nec lacus sollicitudin vehicula. Sed convallis volutpat neque id feugiat. In sed leo vel metus euismod vulputate. Morbi ut sapien malesuada, tristique dolor vel, cursus eros. Cras commodo mi diam, sed auctor diam gravida ultricies. Phasellus eleifend velit arcu, eget pellentesque lacus faucibus vitae.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vulputate vehicula interdum. Fusce lacus dui, mollis nec fringilla vitae, rutrum eu nulla. In dignissim eros quis mauris vulputate semper. Quisque fermentum venenatis turpis in interdum. Donec quis neque imperdiet, lobortis turpis quis, lacinia eros. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Vestibulum fringilla iaculis risus eu dapibus. Proin ac efficitur dui, quis consequat odio. Nulla nisl elit, posuere sit amet rhoncus ac, varius sed quam. Sed ipsum sem, venenatis quis semper a, vestibulum vel orci. Nulla volutpat nulla et ultricies blandit. Cras semper sit amet magna eget bibendum. Etiam aliquet, magna nec rutrum fermentum, augue orci cursus ante, in semper orci felis sed eros. Maecenas neque diam, pulvinar eget convallis ac, mollis et nisl. Pellentesque in lectus vitae eros consectetur gravida.

Phasellus non sagittis sem. Morbi urna ligula, porttitor ac pretium non, dignissim et nunc. Nam quis mi a risus finibus pretium nec eu elit. Fusce nec pulvinar odio. Cras sodales fermentum ex, et lobortis justo convallis et. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris tempor pellentesque est eu ornare. Aenean vehicula quam et felis rutrum luctus. Aliquam erat volutpat. Nulla facilisi. Mauris magna tellus, cursus nec augue nec, rutrum consectetur turpis. Fusce vitae nisl scelerisque, dignissim dui quis, ullamcorper tortor. Suspendisse congue neque at mi venenatis, vitae porttitor orci convallis. Vestibulum malesuada non risus vitae accumsan. Nulla molestie augue ipsum, at iaculis leo cursus non."""

left_panel = Panel(big_text, width=80)

layout = Layout()

layout.update(left_panel)

console.print(layout)
console.print(left_panel)

In this code you can see the difference:

Last paragraph of printing layout
image

Last paragraph of printing the panel by itself

image

You can see above the "Vestibulum.." is cut off for the layout

Does the Layout only apply to the available terminal space? If so how would I then have 2 of these panels side by side.

@willmcgugan
Copy link
Collaborator

The Layout class is designed to divide the visible area in the terminal into parts. It can never be taller than the terminal. If you put content in there that won't fit, it will be clipped. Not sure what you are implementing, but maybe a Table would work?

@gary-conlon
Copy link
Author

gary-conlon commented Sep 1, 2023

The image below I had to hide a lot of sensitive data.

I originally had a layout with 2 panels like this.

Although the layout was being cut off if any field in here was too long.

Could I use a table in a similar format to this?

I have the render group that has text, panels and markdown

The below is a Jira issue viewer for the terminal. So needs to display certain data.

Screenshot_20230901_164830_Teams.jpg

@willmcgugan
Copy link
Collaborator

A Table will generate similar results, but it can grow beyond the height of the terminal. Create a Table and call add_row with your two columns.

@gary-conlon
Copy link
Author

Thanks I will give that a go tomorrow. That's my issue sorted thanks.

Rich is amazing btw, I'm using it so much now. Great work 🙂

@gary-conlon
Copy link
Author

Tables worked nicely, only thing different is that it removed the smooth panel border but im fine with that

image

@github-actions
Copy link

github-actions bot commented Sep 4, 2023

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants