mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
don't refresh if not visible
This commit is contained in:
@@ -414,7 +414,7 @@ class DOMNode(MessagePump):
|
||||
self._auto_refresh_timer = None
|
||||
if interval is not None:
|
||||
self._auto_refresh_timer = self.set_interval(
|
||||
interval, self._automatic_refresh, name=f"auto refresh {self!r}"
|
||||
interval, self.automatic_refresh, name=f"auto refresh {self!r}"
|
||||
)
|
||||
self._auto_refresh = interval
|
||||
|
||||
@@ -476,9 +476,16 @@ class DOMNode(MessagePump):
|
||||
"""Is the node a modal?"""
|
||||
return False
|
||||
|
||||
def _automatic_refresh(self) -> None:
|
||||
"""Perform an automatic refresh (set with auto_refresh property)."""
|
||||
self.refresh()
|
||||
def automatic_refresh(self) -> None:
|
||||
"""Perform an automatic refresh.
|
||||
|
||||
This method is called when you set the `auto_refresh` attribute.
|
||||
You could implement this method if you want to perform additional work
|
||||
during an automatic refresh.
|
||||
|
||||
"""
|
||||
if self.display and self.visible:
|
||||
self.refresh()
|
||||
|
||||
def __init_subclass__(
|
||||
cls,
|
||||
|
||||
@@ -14,11 +14,11 @@ class RefreshApp(App[float]):
|
||||
self.start = time()
|
||||
self.auto_refresh = 0.1
|
||||
|
||||
def _automatic_refresh(self):
|
||||
def automatic_refresh(self):
|
||||
self.count += 1
|
||||
if self.count == 3:
|
||||
self.exit(time() - self.start)
|
||||
super()._automatic_refresh()
|
||||
super().automatic_refresh()
|
||||
|
||||
|
||||
def test_auto_refresh():
|
||||
|
||||
Reference in New Issue
Block a user