mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add methods for getting the width and height of the widget
This commit is contained in:
@@ -172,6 +172,12 @@ class ToggleButton(Static, can_focus=True):
|
||||
else Text.assemble(label, spacer, button)
|
||||
)
|
||||
|
||||
def get_content_width(self, container: Size, viewport: Size) -> int:
|
||||
return self._button.cell_len + (1 if self._label else 0) + self._label.cell_len
|
||||
|
||||
def get_content_height(self, container: Size, viewport: Size, width: int) -> int:
|
||||
return 1
|
||||
|
||||
def toggle(self) -> None:
|
||||
"""Toggle the value of the widget."""
|
||||
self.value = not self.value
|
||||
|
||||
Reference in New Issue
Block a user