1616 ClassVar ,
1717 Collection ,
1818 Generator ,
19+ Generic ,
1920 Iterable ,
2021 NamedTuple ,
2122 Sequence ,
@@ -273,17 +274,19 @@ class Widget(DOMNode):
273274 """Widget may receive focus."""
274275 can_focus_children : bool = True
275276 """Widget's children may receive focus."""
276- expand = Reactive (False )
277- """Rich renderable may expand."""
278- shrink = Reactive (True )
279- """Rich renderable may shrink."""
280- auto_links = Reactive (True )
277+ expand : Reactive [ bool ] = Reactive (False )
278+ """Rich renderable may expand beyond optimal size ."""
279+ shrink : Reactive [ bool ] = Reactive (True )
280+ """Rich renderable may shrink below optimal size ."""
281+ auto_links : Reactive [ bool ] = Reactive (True )
281282 """Widget will highlight links automatically."""
282- disabled = Reactive (False )
283- """The disabled state of the widget. `True` if disabled, `False` if not ."""
283+ disabled : Reactive [ bool ] = Reactive (False )
284+ """Is the widget disabled? Disabled widgets can not be interacted with, and are typically styled to look dimmer ."""
284285
285286 hover_style : Reactive [Style ] = Reactive (Style , repaint = False )
287+ """The current hover style (style under the mouse cursor). Read only."""
286288 highlight_link_id : Reactive [str ] = Reactive ("" )
289+ """The currently highlighted link id. Read only."""
287290
288291 def __init__ (
289292 self ,
@@ -358,21 +361,33 @@ def __init__(
358361 self ._add_children (* children )
359362 self .disabled = disabled
360363
361- virtual_size = Reactive (Size (0 , 0 ), layout = True )
362- auto_width = Reactive (True )
363- auto_height = Reactive (True )
364- has_focus = Reactive (False , repaint = False )
365- mouse_over = Reactive (False , repaint = False )
366- scroll_x = Reactive (0.0 , repaint = False , layout = False )
367- scroll_y = Reactive (0.0 , repaint = False , layout = False )
364+ virtual_size : Reactive [Size ] = Reactive (Size (0 , 0 ), layout = True )
365+ """The virtual (scrollable) [size][textual.geometry.Size] of the widget."""
366+
367+ has_focus : Reactive [bool ] = Reactive (False , repaint = False )
368+ """Does this widget have focus? Read only."""
369+
370+ mouse_over : Reactive [bool ] = Reactive (False , repaint = False )
371+ """Is the mouse over this widget? Read only."""
372+
373+ scroll_x : Reactive [float ] = Reactive (0.0 , repaint = False , layout = False )
374+ """The scroll position on the X axis."""
375+
376+ scroll_y : Reactive [float ] = Reactive (0.0 , repaint = False , layout = False )
377+ """The scroll position on the Y axis."""
378+
368379 scroll_target_x = Reactive (0.0 , repaint = False )
369380 scroll_target_y = Reactive (0.0 , repaint = False )
370- show_vertical_scrollbar = Reactive (False , layout = True )
371- show_horizontal_scrollbar = Reactive (False , layout = True )
372381
373- border_title = _BorderTitle ()
382+ show_vertical_scrollbar : Reactive [bool ] = Reactive (False , layout = True )
383+ """Show a horizontal scrollbar?"""
384+
385+ show_horizontal_scrollbar : Reactive [bool ] = Reactive (False , layout = True )
386+ """SHow a vertical scrollbar?"""
387+
388+ border_title : str | Text | None = _BorderTitle () # type: ignore
374389 """A title to show in the top border (if there is one)."""
375- border_subtitle = _BorderTitle ()
390+ border_subtitle : str | Text | None = _BorderTitle () # type: ignore
376391 """A title to show in the bottom border (if there is one)."""
377392
378393 @property
@@ -408,8 +423,6 @@ def allow_vertical_scroll(self) -> bool:
408423
409424 May be overridden if you want different logic regarding allowing scrolling.
410425
411- Returns:
412- True if the widget may scroll _vertically_.
413426 """
414427 return self .is_scrollable and self .show_vertical_scrollbar
415428
@@ -419,8 +432,6 @@ def allow_horizontal_scroll(self) -> bool:
419432
420433 May be overridden if you want different logic regarding allowing scrolling.
421434
422- Returns:
423- True if the widget may scroll _horizontally_.
424435 """
425436 return self .is_scrollable and self .show_horizontal_scrollbar
426437
@@ -1129,8 +1140,14 @@ def max_scroll_y(self) -> int:
11291140
11301141 @property
11311142 def scrollbar_corner (self ) -> ScrollBarCorner :
1132- """Return the ScrollBarCorner - the cells that appear between the
1133- horizontal and vertical scrollbars (only when both are visible).
1143+ """The scrollbar corner.
1144+
1145+ Note:
1146+ This will *create* a scrollbar corner if one doesn't exist.
1147+
1148+ Returns:
1149+ ScrollBarCorner Widget.
1150+
11341151 """
11351152 from .scrollbar import ScrollBarCorner
11361153
@@ -1142,7 +1159,10 @@ def scrollbar_corner(self) -> ScrollBarCorner:
11421159
11431160 @property
11441161 def vertical_scrollbar (self ) -> ScrollBar :
1145- """Get a vertical scrollbar (create if necessary).
1162+ """The vertical scrollbar (create if necessary).
1163+
1164+ Note:
1165+ This will *create* a scrollbar if one doesn't exist.
11461166
11471167 Returns:
11481168 ScrollBar Widget.
@@ -1160,7 +1180,10 @@ def vertical_scrollbar(self) -> ScrollBar:
11601180
11611181 @property
11621182 def horizontal_scrollbar (self ) -> ScrollBar :
1163- """Get a vertical scrollbar (create if necessary).
1183+ """The a horizontal scrollbar.
1184+
1185+ Note:
1186+ This will *create* a scrollbar if one doesn't exist.
11641187
11651188 Returns:
11661189 ScrollBar Widget.
@@ -1356,7 +1379,12 @@ def content_offset(self) -> Offset:
13561379
13571380 @property
13581381 def content_size (self ) -> Size :
1359- """Get the size of the content area."""
1382+ """The size of the content area.
1383+
1384+ Returns:
1385+ Content area size.
1386+
1387+ """
13601388 return self .region .shrink (self .styles .gutter ).size
13611389
13621390 @property
@@ -1391,8 +1419,13 @@ def container_viewport(self) -> Region:
13911419
13921420 @property
13931421 def virtual_region (self ) -> Region :
1394- """The widget region relative to it's container. Which may not be visible,
1395- depending on scroll offset.
1422+ """The widget region relative to it's container (which may not be visible,
1423+ depending on scroll offset).
1424+
1425+
1426+ Returns:
1427+ The virtual region.
1428+
13961429 """
13971430 try :
13981431 return self .screen .find_widget (self ).virtual_region
@@ -1432,7 +1465,7 @@ def _self_or_ancestors_disabled(self) -> bool:
14321465
14331466 @property
14341467 def focusable (self ) -> bool :
1435- """Can this widget currently receive focus ?"""
1468+ """Can this widget currently be focused ?"""
14361469 return self .can_focus and not self ._self_or_ancestors_disabled
14371470
14381471 @property
@@ -1464,11 +1497,7 @@ def scroll_offset(self) -> Offset:
14641497
14651498 @property
14661499 def is_transparent (self ) -> bool :
1467- """Check if the background styles is not set.
1468-
1469- Returns:
1470- ``True`` if there is background color, otherwise ``False``.
1471- """
1500+ """Does this widget have a transparent background?"""
14721501 return self .is_scrollable and self .styles .background .is_transparent
14731502
14741503 @property
@@ -1546,20 +1575,12 @@ def _layout(self) -> Layout:
15461575
15471576 @property
15481577 def is_container (self ) -> bool :
1549- """Check if this widget is a container (contains other widgets).
1550-
1551- Returns:
1552- True if this widget is a container.
1553- """
1578+ """Is this widget a container (contains other widgets)?"""
15541579 return self .styles .layout is not None or bool (self ._nodes )
15551580
15561581 @property
15571582 def is_scrollable (self ) -> bool :
1558- """Check if this Widget may be scrolled.
1559-
1560- Returns:
1561- True if this widget may be scrolled.
1562- """
1583+ """Can this widget be scrolled?"""
15631584 return self .styles .layout is not None or bool (self ._nodes )
15641585
15651586 @property
@@ -1588,7 +1609,12 @@ def layers(self) -> tuple[str, ...]:
15881609
15891610 @property
15901611 def link_style (self ) -> Style :
1591- """Style of links."""
1612+ """Style of links.
1613+
1614+ Returns:
1615+ Rich style.
1616+
1617+ """
15921618 styles = self .styles
15931619 _ , background = self .background_colors
15941620 link_background = background + styles .link_background
@@ -1605,7 +1631,12 @@ def link_style(self) -> Style:
16051631
16061632 @property
16071633 def link_hover_style (self ) -> Style :
1608- """Style of links with mouse hover."""
1634+ """Style of links underneath the mouse cursor.
1635+
1636+ Returns:
1637+ Rich Style.
1638+
1639+ """
16091640 styles = self .styles
16101641 _ , background = self .background_colors
16111642 hover_background = background + styles .link_hover_background
0 commit comments