Replies: 3 comments 1 reply
-
I landed on this topic because I wanted to include a progress bar within a log text that is being updated in real time. Thanks for the hint, @chelnak! Your code link is no longer valid (I'm sure it's somewhere in the log history though), but I was able to make things work. For future reference, this is the function (based on from textual.layouts.vertical import VerticalLayout
from textual.widget import Widget
from textual.widgets import Static
from textual.views._window_view import WindowChange
async def scrollview_update(scrollview, widgets) -> None:
self = scrollview.window
layout = self.layout
assert isinstance(layout, VerticalLayout)
layout.clear()
for widget in widgets:
widget = widget if isinstance(widget, Widget) else Static(widget)
layout.add(widget)
self.layout.require_update()
self.refresh(layout=True)
await self.emit(WindowChange(self)) |
Beta Was this translation helpful? Give feedback.
-
The ScrollView with Text and Progress bars seems to trigger a bug in Textual. If the contents of the ScrollView are taller than the screen (so scrolling is needed), the display starts "flashing", i.e. quickly switching between two content states which seem to get interleaved line-per-line. This flashing happens while the progress bar is updating. When the progress bar is finished, the display stops flashing but is still corrupted. @willmcgugan Is this something you are aware of? If not, I can try to make a minimal example reproducing this. |
Beta Was this translation helpful? Give feedback.
-
The https://textual.textualize.io/widgets/list_view/ was just published |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently WindowView only accepts a single widget on init and update.
https://github.com/willmcgugan/textual/blob/f574294beb733df0cfd17993401713edf5ed7fca/src/textual/views/_window_view.py#L20
Changing the widget parameter to allow a list of widgets then altering the way it is initialized/updated allows for a nicer experience when using the WindowView class. For example, the user may want to use a ScrollView with multiple widgets inside.
Here is my implementation of WindowView, where I change the functionality to allow for a list of Widgets:
https://github.com/chelnak/jenkins-tui/blob/main/src/jenkins_tui/views/window_view.py
This also fits nicely with your implementation of the VerticalLayout class as you can pass the list directly to it.
I'm interested in your views on this and whether you see any trade offs with my changes... also i'm more than happy to submit a PR if you think it would be of use.
👍
Beta Was this translation helpful? Give feedback.
All reactions