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] Jupyter font, line spacing, and status/spinners not consistent with terminal output #3507

Closed
2 tasks done
mwinokan opened this issue Sep 30, 2024 · 3 comments
Closed
2 tasks done

Comments

@mwinokan
Copy link

Describe the bug

Opening a new issue as #236 did not help me to fully resolve my Jupyter issues.

Namely I have not found a way to set up a rich.console.Console object for use in Jupyter that is consistent with the terminal output.

A default Console object used in Jupyter adds an unwanted line spacing, increased font size, and the reversed text is white on green rather than black on green:

Screenshot 2024-09-30 at 13 02 41

Compare the above to the output when setting force_jupyter=False, force_terminal=True to restore the expected font size, line spacing, and reverse colours (although now the bright colours are not supported):
Screenshot 2024-09-30 at 13 05 13

However, it goes without saying that being limited to using force_terminal=True causes issues with interactive objects such as console.status:

Screenshot 2024-09-30 at 13 07 59

Using the console as the context manager is also not desirable as the interactive status/spinner displays are thereby useless.

I am a big fan of rich and would love to include it across my packages which should behave consistently in both terminal and Jupyter notebooks, any suggestions are much appreciated. Thank you

Platform

Jupyter platform report
╭──────────────────── <class 'rich.console.Console'> ─────────────────────╮
│ A high level console interface.                                         │
│                                                                         │
│ ╭─────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=115 ColorSystem.TRUECOLOR>                           │ │
│ ╰─────────────────────────────────────────────────────────────────────╯ │
│                                                                         │
│     color_system = 'truecolor'                                          │
│         encoding = 'utf-8'                                              │
│             file = <ipykernel.iostream.OutStream object at 0x1033eb610> │
│           height = 100                                                  │
│    is_alt_screen = False                                                │
│ is_dumb_terminal = False                                                │
│   is_interactive = False                                                │
│       is_jupyter = True                                                 │
│      is_terminal = False                                                │
│   legacy_windows = False                                                │
│         no_color = False                                                │
│          options = ConsoleOptions(                                      │
│                        size=ConsoleDimensions(width=115, height=100),   │
│                        legacy_windows=False,                            │
│                        min_width=1,                                     │
│                        max_width=115,                                   │
│                        is_terminal=False,                               │
│                        encoding='utf-8',                                │
│                        max_height=100,                                  │
│                        justify=None,                                    │
│                        overflow=None,                                   │
│                        no_wrap=False,                                   │
│                        highlight=None,                                  │
│                        markup=None,                                     │
│                        height=None                                      │
│                    )                                                    │
│            quiet = False                                                │
│           record = False                                                │
│         safe_box = True                                                 │
│             size = ConsoleDimensions(width=115, height=100)             │
│        soft_wrap = False                                                │
│           stderr = False                                                │
│            style = None                                                 │
│         tab_size = 8                                                    │
│            width = 115                                                  │
╰─────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯
╭──────── Environment Variables ────────╮
│ {                                     │
│     'TERM': 'xterm-color',            │
│     'COLORTERM': None,                │
│     'CLICOLOR': '1',                  │
│     'NO_COLOR': None,                 │
│     'TERM_PROGRAM': 'Apple_Terminal', │
│     'COLUMNS': None,                  │
│     'LINES': None,                    │
│     'JUPYTER_COLUMNS': None,          │
│     'JUPYTER_LINES': None,            │
│     'JPY_PARENT_PID': '95091',        │
│     'VSCODE_VERBOSE_LOGGING': None    │
│ }                                     │
╰───────────────────────────────────────╯
platform="Darwin"
Copy link

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@willmcgugan
Copy link
Collaborator

You are expecting too much. Rich is a terminal out library. Jupyter support is there so you can run code in terminal and Jupyter context. But Rich can't detect what your Jupyter background color is. It can't know the width of your browser. And it can't be certain how the browser's style will impact the output. There are so many implementations of Jupyter, that pleasing everyone is quite literally impossible.

I'm glad you like Rich. But it is a terminal library first and foremost.

Copy link

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