Merge pull request #1610 from Textualize/fix-1607

Fix #1607 to allow programmatic style changes
This commit is contained in:
Rodrigo Girão Serrão
2023-01-31 15:13:24 +00:00
committed by GitHub
7 changed files with 353 additions and 18 deletions

View File

@@ -0,0 +1,29 @@
from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class ProgrammaticScrollbarGutterChange(App[None]):
CSS = """
Grid { grid-size: 2 2; scrollbar-size: 5 5; }
Label { width: 100%; height: 100%; background: red; }
"""
def compose(self):
yield Grid(
Label("one"),
Label("two"),
Label("three"),
Label("four"),
)
def on_key(self, event):
if event.key == "s":
self.query_one(Grid).styles.scrollbar_gutter = "stable"
app = ProgrammaticScrollbarGutterChange()
if __name__ == "__main__":
app().run()