Initially this was "throw most if not all widgets at the display and disable everything" test; but in #2028 it was requested that this be simplified, just using the same widget, in enabled and disabled states. Button seems like a good choice here. To ensure that things work as intended, I'm going with the approach of disabling via a container as that's one big change that the disabled facility brought in.
32 lines
913 B
Python
32 lines
913 B
Python
from textual.app import App, ComposeResult
|
|
from textual.containers import Horizontal
|
|
from textual.widgets import Button
|
|
|
|
class WidgetDisableTestApp(App[None]):
|
|
CSS = """
|
|
Horizontal {
|
|
height: auto;
|
|
}
|
|
|
|
Button {
|
|
width: 1fr;
|
|
}
|
|
"""
|
|
|
|
def compose(self) -> ComposeResult:
|
|
for _ in range(4):
|
|
with Horizontal():
|
|
yield Button()
|
|
yield Button(variant="primary")
|
|
yield Button(variant="success")
|
|
yield Button(variant="warning")
|
|
yield Button(variant="error")
|
|
with Horizontal(disabled=True):
|
|
yield Button()
|
|
yield Button(variant="primary")
|
|
yield Button(variant="success")
|
|
yield Button(variant="warning")
|
|
yield Button(variant="error")
|
|
|
|
if __name__ == "__main__":
|
|
WidgetDisableTestApp().run()
|