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] Live flickers when printing to console with markup=False #2726

Closed
2 tasks done
christiandreher opened this issue Dec 29, 2022 · 2 comments · Fixed by #2852
Closed
2 tasks done

[BUG] Live flickers when printing to console with markup=False #2726

christiandreher opened this issue Dec 29, 2022 · 2 comments · Fixed by #2852

Comments

@christiandreher
Copy link

I couldn't find any relevant issues for me, or at least I did not see the connection.

Describe the bug

When in a Live display, and when printing onto a console with Console.print(..., markup=True), the live will sometimes be rendered without markup as well, causing visual flicker.

Minimum working example:

import random
import time

from rich.console import Console
from rich.live import Live

console = Console()

with Live(console=console, refresh_per_second=4) as live:
    while True:
        time.sleep(0.1)
        rdm = random.random()
        # This text should be printed raw or with markup in bold, depending on rdm.
        live.console.print("[bold]Some text[/bold]", markup=True if rdm >= 0.5 else False)
        # This text should be updated each cycle, but *always* with markup.
        live.update(f"[green]Random:[/green] {rdm}")

I would expect that "markup=True" only affects the text I am using it with, and not the live.

I thought that maybe one can stop the live, print the text without markup, and start the live again afterwards, but this doesn't work. If there are other means of synchronization, then I am not ware of them...

I would be very grateful for help or any workaround.

Platform

Click to expand

Platform Info

 chris@i61nb083  ~  lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.6 LTS
Release:	18.04
Codename:	bionic
 chris@i61nb083  ~  uname -a
Linux i61nb083 5.4.0-126-generic #142~18.04.1-Ubuntu SMP Thu Sep 1 16:25:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
 chris@i61nb083  ~  python --version
Python 3.6.9

Output of python -m rich.diagnose

 (.venv)  chris@i61nb083  ~/tmp/mwe_rich  python -m rich.diagnose
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=211 ColorSystem.TRUECOLOR>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = 'truecolor'                                                   │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'> │
│           height = 54                                                            │
│    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=211, height=54),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=211,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=54,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=211, height=54)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 211                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯

Output of pip freeze | grep rich

 (.venv)  chris@i61nb083  ~/tmp/mwe_rich  pip freeze | grep rich
rich==12.6.0
@github-actions
Copy link

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

@github-actions
Copy link

github-actions bot commented Mar 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

Successfully merging a pull request may close this issue.

1 participant