|
3 | 3 | from textual.color import Color |
4 | 4 | from textual.containers import Horizontal, Vertical, VerticalScroll |
5 | 5 | from textual.design import ColorSystem |
| 6 | +from textual.widget import Widget |
6 | 7 | from textual.widgets import Button, Footer, Label, Static, TabbedContent |
7 | 8 |
|
| 9 | +try: |
| 10 | + from textual.lazy import Lazy |
| 11 | +except ImportError: |
| 12 | + |
| 13 | + def Lazy(widget: Widget) -> Widget: # type: ignore |
| 14 | + return widget |
| 15 | + |
8 | 16 |
|
9 | 17 | class ThemeColorButtons(VerticalScroll): |
10 | 18 | def compose(self) -> ComposeResult: |
@@ -79,15 +87,8 @@ class ColorsApp(App[None]): |
79 | 87 | def compose(self) -> ComposeResult: |
80 | 88 | yield Footer() |
81 | 89 | with ColorTabs("Theme Colors", "Named Colors"): |
82 | | - yield Content(ThemeColorButtons(), id="theme") |
83 | | - yield NamedColorsView() |
84 | | - |
85 | | - def on_mount(self) -> None: |
86 | | - self.call_after_refresh(self.update_view) |
87 | | - |
88 | | - async def update_view(self) -> None: |
89 | | - content = self.query_one("#theme", Content) |
90 | | - await content.mount(ThemeColorsView()) |
| 90 | + yield Content(ThemeColorButtons(), ThemeColorsView(), id="theme") |
| 91 | + yield Lazy(NamedColorsView()) |
91 | 92 |
|
92 | 93 | def on_button_pressed(self, event: Button.Pressed) -> None: |
93 | 94 | self.query(ColorGroup).remove_class("-active") |
|
0 commit comments