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
|
||||
def debug(self) -> bool:
|
||||
"""Is debug mode enabled?"""
|
||||
return "debug" in self.features
|
||||
return "debug" in self.features or constants.DEBUG
|
||||
|
||||
@property
|
||||
def is_headless(self) -> bool:
|
||||
|
||||
@@ -504,6 +504,8 @@ class Widget(DOMNode):
|
||||
"""Time of last scroll."""
|
||||
self._user_scroll_interrupt: bool = False
|
||||
"""Has the user interrupted a scroll to end?"""
|
||||
if self.app.debug:
|
||||
self._preflight()
|
||||
|
||||
@property
|
||||
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."""
|
||||
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:
|
||||
"""Set a widget used to replace the visuals of this widget (used for loading indicator).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user