[BUG] Addressing Dashboard Freeze and Cursor Flicker Issues in Real-Time Data Applications Using Rich
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.
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
Can you provide a MRE to reproduce the issue you're describing?
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)
https://github.com/Textualize/rich/assets/127942818/08c7e935-b163-489c-8741-6cf282810b3c
Here you see the freeze of UI
https://github.com/Textualize/rich/assets/127942818/31ad1218-95fa-4a55-9475-88f641667294
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?
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.
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.
Hi, its exactly the same in powershell terminal. Could you pls advice how to realize a Dashboard easiliy in Textual?
best
Will is suggesting that you look at Windows Terminal.
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