kainoir

Scroll End - Super Minimal

Jul 7th, 2025 (edited)
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. """
  2. These are all that's really needed to reproduce the Error.
  3.  
  4. Widgets get added via the add_to_screen which then should trigger scolling.
  5. """
  6.  
  7. from textual.app import App
  8. from textual.containers import ScrollableContainer, Vertical
  9. from textual.widgets import Static
  10.  
  11.  
  12. class SimpleApp(App):
  13.     MAIN = "main"
  14.     CONTENT_WRAPPER = "wrapper"
  15.     INSTRUCTIONS = "Press \[Enter] to add lines, 'c' to clear"
  16.  
  17.     def compose(self):
  18.         yield ScrollableContainer(
  19.             Vertical(id=self.MAIN),
  20.             id=self.CONTENT_WRAPPER
  21.         )
  22.  
  23.     async def add_to_screen(self, widget):
  24.         # This is how widgets are added
  25.         main = self.get_widget_by_id(self.MAIN)
  26.         await main.mount(widget)
  27.         await self.scroll_to_end()
  28.  
  29.     async def scroll_to_end(self):
  30.         # This is the method used to scroll to the end
  31.         container = self.get_widget_by_id(self.CONTENT_WRAPPER)
  32.         container.scroll_end()
  33.  
Advertisement
Add Comment
Please, Sign In to add comment