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] Addressing Dashboard Freeze and Cursor Flicker Issues in Real-Time Data Applications Using Rich #3264

Open
kaidaniel82 opened this issue Jan 25, 2024 · 11 comments

Comments

@kaidaniel82
Copy link

Hi,

I have created a dashboard with real-time data using Rich. However, I am encountering two issues. First, the input cursor from the terminal occasionally flickers, which leads people to click on the UI, causing it to freeze until I resize the terminal window. Second, it appears that when the UI freezes due to mouse clicks, some of my backend processes, like logging to files, also start to freeze.

python == 3.11
rich==13.7.0

Running on Windows 11 and Windows Server 2022.

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

@TomJGooding
Copy link

TomJGooding commented Jan 25, 2024

Can you provide a MRE to reproduce the issue you're describing?

@kaidaniel82
Copy link
Author

kaidaniel82 commented Jan 25, 2024

I deleted all what is not needed ... but it shows the issue.

If I ran tis code on windows 2022 Server it freaks out...

from rich.console import Console
from rich.panel import Panel
from rich.table import Table
from rich.layout import Layout
from rich.text import Text
from datetime import datetime
from rich.live import Live
import time

console = Console()


def make_layout():
    layout = Layout(name="root")

    layout.split_column(
        Layout(name="header", size=3),
        Layout(name="main", size=8),
        Layout(name="footer", size=5),
    )

    layout["main"].split_row(
        Layout(name="account"),
        Layout(name="indicator"),
        Layout(name="money_management"),
        Layout(name="license"),
        Layout(name="connectivity"),
    )

    return layout


class Header:
    def __init__(self):
        pass

    def __rich__(self) -> Panel:
        market_info = f"Next Opening in {5}h {5}min"
        grid = Table.grid(expand=True)
        grid.add_column(justify="left")
        grid.add_column(justify="center", ratio=1)
        grid.add_column(justify="right")
        grid.add_row(
            Text("H | Version 1.1"),
            Text(market_info, style="red"),
            Text(datetime.today().strftime("%Y-%m-%d %H:%M:%S")),
        )
        return Panel(grid, style="bold black on #003366")


layout = make_layout()
layout["header"].update(Header())

console.clear()
with Live(layout, refresh_per_second=20, screen=True):
    while True:
        time.sleep(1)

@kaidaniel82
Copy link
Author

Screen.Recording.2024-01-25.at.02.11.59.mov

@kaidaniel82
Copy link
Author

kaidaniel82 commented Jan 25, 2024

Here you see the freeze of UI

Screen.Recording.2024-01-25.at.02.15.01.mov

@davep
Copy link
Contributor

davep commented Jan 25, 2024

I get the same pause effect with a Windows console window if I run this program, no Rich involved at all:

from time import sleep

for n in range(10_000):
    print(str(n))
    sleep(1)

This seems to be standard behaviour for Windows console and nothing to do with Rich.

I'm no Windows person, but a quick search online suggests this is related to something called "Quick Edit Mode", perhaps?

@kaidaniel82
Copy link
Author

kaidaniel82 commented Jan 25, 2024

Hi,
by "Quick Edit Mode" deactivate makes the freeze issue solved but it is still massive flickering. I also still see the Cursor flickering.

thanks a lot.
Screenshot 2024-01-25 at 11 31 00

@willmcgugan
Copy link
Collaborator

You may want to try the new Windows Terminal. The legacy terminal has a lot of issues. You also may want to consider the Textual for things like this.

@kaidaniel82
Copy link
Author

Hi,
its exactly the same in powershell terminal. Could you pls advice how to realize a Dashboard easiliy in Textual?

best

@davep
Copy link
Contributor

davep commented Jan 25, 2024

Will is suggesting that you look at Windows Terminal.

@kaidaniel82
Copy link
Author

kaidaniel82 commented Jan 25, 2024

Thanks, i will give it a try. However i can not guarantee that this new styled terminal is installed on the clients machine.
I will update my findings here...

looks like there is a github repository enabling download
https://github.com/microsoft/terminal

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

4 participants