You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using layout.Layout.refresh_screen [0] in personal projects for fast layout updates with very low CPU usage with great success. I'm only ever on Mac or Linux boxes, so, before I use it for public facing projects, is refresh_screen stable across operating systems?
The only reference to the method I can find in either the documentation or source code is in the test_layout.py file that claims it does not run on windows [1]
@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
I don't have access to a Windows machine at the moment but I did spin up a Win11 VM in UTM and it appeared to work fine in the default terminal.
Below is a quick demo of using layout.refresh_screen compared to relying on Live's default auto refresh.
The first run, which uses refresh_screen, will update instantaneously while also using very little CPU. The second run, which relies on Live's default refresh_per_second setting of 4, will be "chunkier" in its updates, since it's only updating 4 times per second, but it will also use considerably more CPU.
I understand that Live will be more responsive in the sense that it will automatically adjust the Panel sizes when the terminal is resized but that's easy enough to track manually and call Live.update when needed.
I initially did a test calling Live.update manually on each iteration but it consumed so much CPU it was not a feasible solution.
If refresh_screen is stable across operating systems, I would be glad to write a quick example for the examples folder.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have been using
layout.Layout.refresh_screen
[0] in personal projects for fast layout updates with very low CPU usage with great success. I'm only ever on Mac or Linux boxes, so, before I use it for public facing projects, isrefresh_screen
stable across operating systems?The only reference to the method I can find in either the documentation or source code is in the
test_layout.py
file that claims it does not run on windows [1]I don't have access to a Windows machine at the moment but I did spin up a Win11 VM in UTM and it appeared to work fine in the default terminal.
Below is a quick demo of using
layout.refresh_screen
compared to relying onLive
's default auto refresh.The first run, which uses
refresh_screen
, will update instantaneously while also using very little CPU. The second run, which relies onLive
's defaultrefresh_per_second
setting of 4, will be "chunkier" in its updates, since it's only updating 4 times per second, but it will also use considerably more CPU.I understand that
Live
will be more responsive in the sense that it will automatically adjust thePanel
sizes when the terminal is resized but that's easy enough to track manually and callLive.update
when needed.I initially did a test calling
Live.update
manually on each iteration but it consumed so much CPU it was not a feasible solution.If
refresh_screen
is stable across operating systems, I would be glad to write a quick example for the examples folder.[0] https://github.com/Textualize/rich/blob/master/rich/layout.py#L328
[1] https://github.com/Textualize/rich/blob/master/tests/test_layout.py#L86
Beta Was this translation helpful? Give feedback.
All reactions