File tree Expand file tree Collapse file tree 2 files changed +16
-24
lines changed Expand file tree Collapse file tree 2 files changed +16
-24
lines changed Original file line number Diff line number Diff line change 22title : " textual.compose" 
33--- 
44
5- ::: textual.compose
5+ ::: textual.compose.compose 
Original file line number Diff line number Diff line change 1- """ 
2- 
3- The compose method allows you to mount widgets using the same syntax as the [compose][textual.widget.Widget.compose] method. 
4- 
5- ```python 
6- 
7-     def on_key(self, event:events.Key) -> None: 
8- 
9-         def add_key(key:str) -> ComposeResult: 
10-             with containers.HorizontalGroup(): 
11-                 yield Label("You pressed:") 
12-                 yield Label(key) 
13- 
14-         self.mount_all( 
15-             compose(self, add_key(event.key)), 
16-         ) 
17- 
18- ``` 
19- 
20- 
21- """ 
22- 
231from  __future__ import  annotations 
242
253from  typing  import  TYPE_CHECKING 
@@ -34,7 +12,21 @@ def add_key(key:str) -> ComposeResult:
3412def  compose (
3513    node : App  |  Widget , compose_result : ComposeResult  |  None  =  None 
3614) ->  list [Widget ]:
37-     """Compose child widgets. 
15+     """Compose child widgets from a generator in the same way as [compose][textual.widget.Widget.compose]. 
16+ 
17+     Example: 
18+         ```python 
19+             def on_key(self, event:events.Key) -> None: 
20+ 
21+                 def add_key(key:str) -> ComposeResult: 
22+                     with containers.HorizontalGroup(): 
23+                         yield Label("You pressed:") 
24+                         yield Label(key) 
25+ 
26+                 self.mount_all( 
27+                     compose(self, add_key(event.key)), 
28+                 ) 
29+         ``` 
3830
3931    Args: 
4032        node: The parent node. 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments