mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Start a snapshot test for disabled widgets
Eventually this should likely have every user-interactive widget within it. Perhaps every widget.
This commit is contained in:
58
tests/snapshot_tests/snapshot_apps/disable_widgets.py
Normal file
58
tests/snapshot_tests/snapshot_apps/disable_widgets.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Vertical
|
||||
from textual.widgets import (
|
||||
Header, Footer, Button, DataTable, Input, ListView, ListItem, Label, Tree, TextLog
|
||||
)
|
||||
|
||||
class WidgetDisableTestApp( App[ None ] ):
|
||||
|
||||
CSS = """
|
||||
DataTable, ListView, Tree {
|
||||
height: 2;
|
||||
}
|
||||
"""
|
||||
|
||||
@property
|
||||
def data_table(self) -> DataTable:
|
||||
data_table = DataTable()
|
||||
data_table.add_columns( "Column 1", "Column 2", "Column 3", "Column 4" )
|
||||
data_table.add_rows(
|
||||
[ ( str( n ), str( n * 10 ), str( n * 100 ), str( n * 1000 ) ) for n in range( 100 ) ]
|
||||
)
|
||||
return data_table
|
||||
|
||||
@property
|
||||
def list_view( self ) -> ListView:
|
||||
return ListView(
|
||||
*[ ListItem( Label( f"This is list item {n}" ) ) for n in range( 20 ) ]
|
||||
)
|
||||
|
||||
@property
|
||||
def test_tree( self ) -> Tree:
|
||||
tree = Tree[None]( label="This is a test tree" )
|
||||
for n in range( 10 ):
|
||||
tree.root.add_leaf( f"Leaf {n}" )
|
||||
tree.root.expand()
|
||||
return tree
|
||||
|
||||
def compose( self ) -> ComposeResult:
|
||||
yield Header()
|
||||
yield Vertical(
|
||||
Button(),
|
||||
self.data_table,
|
||||
self.list_view,
|
||||
self.test_tree,
|
||||
TextLog(),
|
||||
Input(),
|
||||
Input(placeholder="This is an empty input with a placeholder"),
|
||||
Input("This is some text in an input"),
|
||||
id="test-container",
|
||||
)
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.query_one(TextLog).write("Hello, World!")
|
||||
self.query_one("#test-container", Vertical).disabled = True
|
||||
|
||||
if __name__ == "__main__":
|
||||
WidgetDisableTestApp().run()
|
||||
Reference in New Issue
Block a user