mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
docstrings
This commit is contained in:
@@ -210,7 +210,9 @@ class Screen(Widget):
|
|||||||
virtual_size,
|
virtual_size,
|
||||||
container_size,
|
container_size,
|
||||||
) in self._compositor:
|
) in self._compositor:
|
||||||
widget.size_updated(unclipped_region.size, virtual_size, container_size)
|
widget._size_updated(
|
||||||
|
unclipped_region.size, virtual_size, container_size
|
||||||
|
)
|
||||||
if widget in send_resize:
|
if widget in send_resize:
|
||||||
widget.post_message_no_wait(
|
widget.post_message_no_wait(
|
||||||
events.Resize(
|
events.Resize(
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class ScrollView(Widget):
|
|||||||
"""
|
"""
|
||||||
return self.virtual_size.height
|
return self.virtual_size.height
|
||||||
|
|
||||||
def size_updated(
|
def _size_updated(
|
||||||
self, size: Size, virtual_size: Size, container_size: Size
|
self, size: Size, virtual_size: Size, container_size: Size
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Called when size is updated.
|
"""Called when size is updated.
|
||||||
|
|||||||
@@ -313,6 +313,8 @@ class Widget(DOMNode):
|
|||||||
def get_content_width(self, container: Size, viewport: Size) -> int:
|
def get_content_width(self, container: Size, viewport: Size) -> int:
|
||||||
"""Gets the width of the content area.
|
"""Gets the width of the content area.
|
||||||
|
|
||||||
|
May be overridden in a subclass.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
container (Size): Size of the container (immediate parent) widget.
|
container (Size): Size of the container (immediate parent) widget.
|
||||||
viewport (Size): Size of the viewport.
|
viewport (Size): Size of the viewport.
|
||||||
@@ -343,6 +345,8 @@ class Widget(DOMNode):
|
|||||||
def get_content_height(self, container: Size, viewport: Size, width: int) -> int:
|
def get_content_height(self, container: Size, viewport: Size, width: int) -> int:
|
||||||
"""Gets the height (number of lines) in the content area.
|
"""Gets the height (number of lines) in the content area.
|
||||||
|
|
||||||
|
May be overridden in a subclass.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
container (Size): Size of the container (immediate parent) widget.
|
container (Size): Size of the container (immediate parent) widget.
|
||||||
viewport (Size): Size of the viewport.
|
viewport (Size): Size of the viewport.
|
||||||
@@ -435,7 +439,7 @@ class Widget(DOMNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def vertical_scrollbar(self) -> ScrollBar:
|
def vertical_scrollbar(self) -> ScrollBar:
|
||||||
"""Get a vertical scrollbar (create if necessary)
|
"""Get a vertical scrollbar (create if necessary).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
ScrollBar: ScrollBar Widget.
|
ScrollBar: ScrollBar Widget.
|
||||||
@@ -452,7 +456,7 @@ class Widget(DOMNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def horizontal_scrollbar(self) -> ScrollBar:
|
def horizontal_scrollbar(self) -> ScrollBar:
|
||||||
"""Get a vertical scrollbar (create if necessary)
|
"""Get a vertical scrollbar (create if necessary).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
ScrollBar: ScrollBar Widget.
|
ScrollBar: ScrollBar Widget.
|
||||||
@@ -515,7 +519,11 @@ class Widget(DOMNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def scrollbar_size_vertical(self) -> int:
|
def scrollbar_size_vertical(self) -> int:
|
||||||
"""Get the width used by the *vertical* scrollbar."""
|
"""Get the width used by the *vertical* scrollbar.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: Number of columns in the vertical scrollbar.
|
||||||
|
"""
|
||||||
styles = self.styles
|
styles = self.styles
|
||||||
if styles.scrollbar_gutter == "stable" and styles.overflow_y == "auto":
|
if styles.scrollbar_gutter == "stable" and styles.overflow_y == "auto":
|
||||||
return styles.scrollbar_size_vertical
|
return styles.scrollbar_size_vertical
|
||||||
@@ -523,7 +531,11 @@ class Widget(DOMNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def scrollbar_size_horizontal(self) -> int:
|
def scrollbar_size_horizontal(self) -> int:
|
||||||
"""Get the height used by the *horizontal* scrollbar."""
|
"""Get the height used by the *horizontal* scrollbar.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: Number of rows in the horizontal scrollbar.
|
||||||
|
"""
|
||||||
styles = self.styles
|
styles = self.styles
|
||||||
if styles.scrollbar_gutter == "stable" and styles.overflow_x == "auto":
|
if styles.scrollbar_gutter == "stable" and styles.overflow_x == "auto":
|
||||||
return styles.scrollbar_size_horizontal
|
return styles.scrollbar_size_horizontal
|
||||||
@@ -531,7 +543,7 @@ class Widget(DOMNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def scrollbar_gutter(self) -> Spacing:
|
def scrollbar_gutter(self) -> Spacing:
|
||||||
"""Spacing required to fit scrollbar(s)
|
"""Spacing required to fit scrollbar(s).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Spacing: Scrollbar gutter spacing.
|
Spacing: Scrollbar gutter spacing.
|
||||||
@@ -619,7 +631,7 @@ class Widget(DOMNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def container_viewport(self) -> Region:
|
def container_viewport(self) -> Region:
|
||||||
"""The viewport region (parent window)
|
"""The viewport region (parent window).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Region: The region that contains this widget.
|
Region: The region that contains this widget.
|
||||||
@@ -1079,6 +1091,7 @@ class Widget(DOMNode):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
region (Region): A region that should be visible.
|
region (Region): A region that should be visible.
|
||||||
|
spacing (Spacing | None, optional): Optional spacing around the region. Defaults to None.
|
||||||
animate (bool, optional): Enable animation. Defaults to True.
|
animate (bool, optional): Enable animation. Defaults to True.
|
||||||
spacing (Spacing): Space to subtract from the window region.
|
spacing (Spacing): Space to subtract from the window region.
|
||||||
|
|
||||||
@@ -1254,9 +1267,16 @@ class Widget(DOMNode):
|
|||||||
"""Update from CSS if has focus state changes."""
|
"""Update from CSS if has focus state changes."""
|
||||||
self.app.update_styles(self)
|
self.app.update_styles(self)
|
||||||
|
|
||||||
def size_updated(
|
def _size_updated(
|
||||||
self, size: Size, virtual_size: Size, container_size: Size
|
self, size: Size, virtual_size: Size, container_size: Size
|
||||||
) -> None:
|
) -> None:
|
||||||
|
"""Called when the widget's size is updated.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
size (Size): Screen size.
|
||||||
|
virtual_size (Size): Virtual (scrollable) size.
|
||||||
|
container_size (Size): Container size (size of parent).
|
||||||
|
"""
|
||||||
if self._size != size or self.virtual_size != virtual_size:
|
if self._size != size or self.virtual_size != virtual_size:
|
||||||
self._size = size
|
self._size = size
|
||||||
self.virtual_size = virtual_size
|
self.virtual_size = virtual_size
|
||||||
|
|||||||
Reference in New Issue
Block a user