File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ from textual .app import App , ComposeResult
2+ from textual .widgets import Label
3+
4+
5+ async def test_hide () -> None :
6+ """Check that setting visibility produces Hide messages."""
7+ # https://github.com/Textualize/textual/issues/3460
8+ visibility : list [bool ] = []
9+
10+ class ShowHideLabel (Label ):
11+ def on_show (self ) -> None :
12+ visibility .append (True )
13+
14+ def on_hide (self ) -> None :
15+ visibility .append (False )
16+
17+ class ShowHideApp (App [None ]):
18+ BINDINGS = [("space" , "toggle_label" )]
19+
20+ def compose (self ) -> ComposeResult :
21+ yield ShowHideLabel ("Here I am" )
22+
23+ def action_toggle_label (self ) -> None :
24+ self .query_one (ShowHideLabel ).visible = not self .query_one (
25+ ShowHideLabel
26+ ).visible
27+
28+ app = ShowHideApp ()
29+ async with app .run_test () as pilot :
30+ assert visibility == [True ]
31+ await pilot .press ("space" )
32+ assert visibility == [True , False ]
33+ await pilot .press ("space" )
34+ assert visibility == [True , False , True ]
You can’t perform that action at this time.
0 commit comments