diff --git a/docs/index.md b/docs/index.md index 17ac22c5f..81fbfcbb0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,19 +10,19 @@ Creating a TUI can be challenging. It may be easier to create a GUI or web appli Textual seeks to lower the difficulty level of building a TUI by borrowing developments from the web world and to a lesser extent desktop applications. The goal is for it to be as easy to develop a TUI for your project as it would be to add a command line interface.XX -=== "Python" +=== "simple.py" ```python --8<-- "docs/examples/simple.py" ``` -=== "CSS" +=== "simple.css" - ```python + ```scss --8<-- "docs/examples/simple.css" ``` -=== "Terminal" +=== "Result" ```{.textual path="docs/examples/simple.py" columns="80" lines="24"} ``` diff --git a/poetry.lock b/poetry.lock index d0a40e58a..f69a66ef7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -650,7 +650,7 @@ pyyaml = "*" [[package]] name = "rich" -version = "12.4.3" +version = "12.4.4" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" category = "main" optional = false @@ -1360,8 +1360,8 @@ pyyaml-env-tag = [ {file = "pyyaml_env_tag-0.1.tar.gz", hash = "sha256:70092675bda14fdec33b31ba77e7543de9ddc88f2e5b99160396572d11525bdb"}, ] rich = [ - {file = "rich-12.4.3-py3-none-any.whl", hash = "sha256:26ef784599a9ab905ade34ff28904e4fbe9bce16e02c33c78b0229551104c146"}, - {file = "rich-12.4.3.tar.gz", hash = "sha256:e7550ca19aec51b216ae4c34bfce82e94a0c79bdbf95cafbf42f343d0fb3f45a"}, + {file = "rich-12.4.4-py3-none-any.whl", hash = "sha256:d2bbd99c320a2532ac71ff6a3164867884357da3e3301f0240090c5d2fdac7ec"}, + {file = "rich-12.4.4.tar.gz", hash = "sha256:4c586de507202505346f3e32d1363eb9ed6932f0c2f63184dea88983ff4971e2"}, ] six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, diff --git a/src/textual/app.py b/src/textual/app.py index 31d91b8dc..20f448258 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -763,6 +763,11 @@ class App(Generic[ReturnType], DOMNode): self._log_console = None async def _ready(self) -> None: + """Called immediately prior to processing messages. + + May be used as a hook for any operations that should run first. + + """ try: screenshot_timer = float(os.environ.get("TEXTUAL_SCREENSHOT", "0")) except ValueError: @@ -772,8 +777,9 @@ class App(Generic[ReturnType], DOMNode): return async def on_screenshot(): + """Used by docs plugin.""" svg = self.export_screenshot() - self._screenshot = svg + self._screenshot = svg # type: ignore await self.shutdown() self.set_timer(screenshot_timer, on_screenshot) @@ -880,7 +886,7 @@ class App(Generic[ReturnType], DOMNode): Args: renderable (RenderableType): A Rich renderable. """ - if self._running and not self._closed: + if self._running and not self._closed and not self.is_headless: console = self.console if self._sync_available: console.file.write("\x1bP=1s\x1b\\") diff --git a/src/textual/widget.py b/src/textual/widget.py index 11d17666c..d3bdb491c 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -399,6 +399,8 @@ class Widget(DOMNode): scrolled_x = scrolled_y = False if animate: # TODO: configure animation speed + if duration is None and speed is None: + speed = 50 if x is not None: self.scroll_target_x = x if x != self.scroll_x: