Replies: 1 comment 4 replies
-
I just tested from textual.app import App, ComposeResult
from textual.containers import Grid
from textual.widgets import TextLog
from textual.reactive import var
class TextLogMaxLinesApp( App[ None ] ):
CSS = """
Grid {
grid-size: 3;
}
TextLog {
border: solid yellow;
}
"""
line: var[ int ] = var( 0 )
def compose( self ) -> ComposeResult:
with Grid():
for _ in range( 9 ):
yield TextLog( max_lines=10 )
def watch_line( self ) -> None:
for log in self.query( TextLog ):
log.write( str( self.line ) )
def next_line( self ) -> None:
self.line += 1
def on_mount( self ) -> None:
self.set_interval( 1 / 5, self.next_line )
if __name__ == "__main__":
TextLogMaxLinesApp().run() and I'm seeing the behaviour you're expecting to see: Screen.Recording.2023-05-15.at.09.11.18.mov |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am using the TextLog widget and I want to use it to provide a recent subset of information that is being written to a log file.
Becuase it will be used in code that is logging information up to 5 times per second, I want to limit the length of the log using the max lines behaviour.
However, I was expecting max lines to work in a fifo manner - i.e you could keep updating beying the line limit and it would pop out the oldest entry to replace it. It doesn't appear to work that way - rather the log seems to be limited at that length and no further info can be added. Am I correct and is there a suggested way of having a fifo type log?
Thanks for a great tool!
Beta Was this translation helpful? Give feedback.
All reactions