mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
preflight checks
This commit is contained in:
@@ -1026,7 +1026,7 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
@property
|
@property
|
||||||
def debug(self) -> bool:
|
def debug(self) -> bool:
|
||||||
"""Is debug mode enabled?"""
|
"""Is debug mode enabled?"""
|
||||||
return "debug" in self.features
|
return "debug" in self.features or constants.DEBUG
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_headless(self) -> bool:
|
def is_headless(self) -> bool:
|
||||||
|
|||||||
@@ -504,6 +504,8 @@ class Widget(DOMNode):
|
|||||||
"""Time of last scroll."""
|
"""Time of last scroll."""
|
||||||
self._user_scroll_interrupt: bool = False
|
self._user_scroll_interrupt: bool = False
|
||||||
"""Has the user interrupted a scroll to end?"""
|
"""Has the user interrupted a scroll to end?"""
|
||||||
|
if self.app.debug:
|
||||||
|
self._preflight()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_mounted(self) -> bool:
|
def is_mounted(self) -> bool:
|
||||||
@@ -651,6 +653,19 @@ class Widget(DOMNode):
|
|||||||
"""Text selection information, or `None` if no text is selected in this widget."""
|
"""Text selection information, or `None` if no text is selected in this widget."""
|
||||||
return self.screen.selections.get(self, None)
|
return self.screen.selections.get(self, None)
|
||||||
|
|
||||||
|
def _preflight(self) -> None:
|
||||||
|
"""Called in debug mode to do preflight checks.
|
||||||
|
|
||||||
|
Errors are reported via self.log.
|
||||||
|
|
||||||
|
"""
|
||||||
|
from textual.screen import Screen
|
||||||
|
|
||||||
|
if not isinstance(self, Screen) and hasattr(self, "CSS"):
|
||||||
|
self.log.warning(
|
||||||
|
f"'{self.__class__.__name__}.CSS' will be ignored (use 'DEFAULT_CSS' class variable for widgets)"
|
||||||
|
)
|
||||||
|
|
||||||
def _cover(self, widget: Widget) -> None:
|
def _cover(self, widget: Widget) -> None:
|
||||||
"""Set a widget used to replace the visuals of this widget (used for loading indicator).
|
"""Set a widget used to replace the visuals of this widget (used for loading indicator).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user