How to make a Window's contents scrollable, auto-width, and not centered? #59
Replies: 1 comment
-
Sadly, the scrollbar part is not available at the moment, but it's on it's way. Other than that, what you want is somewhat displayed in the scrolling sandbox file. Some of the code is a bit behind on the API, so just look at these. I have a feeling you might run into some performance issues with this sadly. As I said in the issue above, the current scrolling behaviour is kind of not very smart, so it does a lot of extra rendering. One small gain to performance you can have would be to split all the lines into their own labels, like so: ...
body = ptg.Window(
*[
ptg.Label(line, parent_align=0)
for line in ptg.tim.get_markup(test_session_start_results).splitlines()
]
overflow=ptg.Overflow.SCROLL,
)
... Here, |
Beta Was this translation helpful? Give feedback.
-
I've defined a basic TUI with a Window object that holds ANSI-encoded test result data (several pages long). I have it rendering in the Window object, but it doesn't match what would actually be seen on the command line when pytest is run:
vs what I see:
The main things I see that don't meet my expectations are: (1) text should be left-justified, not centered; (2) line width should match that of the terminal in which it was run (is there an auto-width or wrap feature?); (3) since my text is longer than the screen height, I'd like to make it scrollable with a tab/slider on the right.
Code (yes, very hack-y, I admit!):
Beta Was this translation helpful? Give feedback.
All reactions