From ec14ed25d2beeacbc112b4454f63d2d9dbf6cac6 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 4 Oct 2022 11:26:23 +0100 Subject: [PATCH 1/8] Document Footer widget --- docs/examples/widgets/footer.py | 15 +++++++++++++ docs/reference/footer.md | 1 + docs/widgets/button.md | 4 ++-- docs/widgets/footer.md | 40 +++++++++++++++++++++++++++++++++ mkdocs.yml | 3 ++- sandbox/darren/file_search.py | 10 ++++----- sandbox/darren/file_search.scss | 8 +------ src/textual/widgets/_footer.py | 16 ++++++------- src/textual/widgets/_input.py | 8 +++---- 9 files changed, 78 insertions(+), 27 deletions(-) create mode 100644 docs/examples/widgets/footer.py create mode 100644 docs/reference/footer.md diff --git a/docs/examples/widgets/footer.py b/docs/examples/widgets/footer.py new file mode 100644 index 000000000..47d9c9aa6 --- /dev/null +++ b/docs/examples/widgets/footer.py @@ -0,0 +1,15 @@ +from textual.app import App, ComposeResult +from textual.binding import Binding +from textual.widgets import Footer + + +class FooterApp(App): + BINDINGS = [Binding(key="q", action="quit", description="Quit the app")] + + def compose(self) -> ComposeResult: + yield Footer() + + +if __name__ == "__main__": + app = FooterApp() + app.run() diff --git a/docs/reference/footer.md b/docs/reference/footer.md new file mode 100644 index 000000000..604c2ef6a --- /dev/null +++ b/docs/reference/footer.md @@ -0,0 +1 @@ +::: textual.widgets.Footer diff --git a/docs/widgets/button.md b/docs/widgets/button.md index 44f9cfb2d..2b1008e85 100644 --- a/docs/widgets/button.md +++ b/docs/widgets/button.md @@ -38,11 +38,11 @@ Clicking any of the non-disabled buttons in the example app below will result in | `variant` | `str` | `"default"` | Semantic styling variant. One of `default`, `primary`, `success`, `warning`, `error`. | | `disabled` | `bool` | `False` | Whether the button is disabled or not. Disabled buttons cannot be focused or clicked, and are styled in a way that suggests this. | -## Events +## Messages ### Pressed -The `Button.Pressed` event is sent when the button is pressed. +The `Button.Pressed` message is sent when the button is pressed. - [x] Bubbles diff --git a/docs/widgets/footer.md b/docs/widgets/footer.md index 571fbcaac..788c8e8ab 100644 --- a/docs/widgets/footer.md +++ b/docs/widgets/footer.md @@ -1 +1,41 @@ # Footer + +## Description + +A simple footer widget which is docked to the bottom of its parent container. Displays +available keybindings for the currently focused widget. + +## Example + +The example below shows an app with a single keybinding that contains only a `Footer` +widget. Notice how the `Footer` automatically displays the keybind. + +=== "Output" + + ```{.textual path="docs/examples/widgets/footer.py"} + ``` + +=== "button.py" + + ```python + --8<-- "docs/examples/widgets/footer.py" + ``` + +## Reactive Attributes + +| Name | Type | Default | Description | +|-----------------|-------|---------|-----------------------------------------------------------------------------------------------------------| +| `highlight_key` | `str` | `None` | Stores the currently highlighted key. This is typically the key the cursor is hovered over in the footer. | + +## Messages + +This widget sends no messages. + +## Additional Notes + +* You can prevent keybindings from appearing in the footer by setting the `show` argument of the `Binding` to `False`. +* You can customize the text that appears for the key itself in the footer using the `key_display` argument of `Binding`. + +## See Also + +* [Footer](../reference/footer.md) code reference diff --git a/mkdocs.yml b/mkdocs.yml index 2a9a020a8..f0f47ce7e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -51,7 +51,7 @@ nav: - "events/screen_suspend.md" - "events/show.md" - Styles: - - "styles/index.md" + - "styles/index.md" - "styles/align.md" - "styles/background.md" - "styles/border.md" @@ -100,6 +100,7 @@ nav: - "reference/containers.md" - "reference/dom_node.md" - "reference/events.md" + - "reference/footer.md" - "reference/geometry.md" - "reference/index.md" - "reference/message_pump.md" diff --git a/sandbox/darren/file_search.py b/sandbox/darren/file_search.py index ab93b29fb..da25f983a 100644 --- a/sandbox/darren/file_search.py +++ b/sandbox/darren/file_search.py @@ -11,7 +11,7 @@ from textual.app import App from textual.geometry import Size from textual.reactive import Reactive from textual.widget import Widget -from textual.widgets.text_input import TextInput, TextWidgetBase +from textual.widgets._input import Input def get_files() -> list[Path]: @@ -53,12 +53,12 @@ class FileSearchApp(App): def on_mount(self) -> None: self.file_table = FileTable(id="file_table", files=list(Path.cwd().iterdir())) - self.search_bar = TextInput(placeholder="Search for files...") - self.search_bar.focus() - self.mount(file_table_wrapper=Widget(self.file_table)) + self.search_bar = Input(placeholder="Search for files...") + # self.search_bar.focus() self.mount(search_bar=self.search_bar) + self.mount(file_table_wrapper=Widget(self.file_table)) - def on_text_input_changed(self, event: TextInput.Changed) -> None: + def on_input_changed(self, event: Input.Changed) -> None: self.file_table.filter = event.value diff --git a/sandbox/darren/file_search.scss b/sandbox/darren/file_search.scss index 6b8839216..b1d95cea6 100644 --- a/sandbox/darren/file_search.scss +++ b/sandbox/darren/file_search.scss @@ -1,12 +1,8 @@ Screen { - - + } #file_table_wrapper { - dock: bottom; - height: auto; - overflow: auto auto; scrollbar-color: $accent-darken-1; } @@ -15,7 +11,5 @@ Screen { } #search_bar { - dock: bottom; - background: $accent; height: 1; } diff --git a/src/textual/widgets/_footer.py b/src/textual/widgets/_footer.py index 59deb955c..26534a4e9 100644 --- a/src/textual/widgets/_footer.py +++ b/src/textual/widgets/_footer.py @@ -20,18 +20,18 @@ class Footer(Widget): dock: bottom; height: 1; } - Footer > .footer--highlight { - background: $accent-darken-1; + Footer > .footer--highlight { + background: $accent-darken-1; } - Footer > .footer--highlight-key { - background: $secondary; - text-style: bold; + Footer > .footer--highlight-key { + background: $secondary; + text-style: bold; } Footer > .footer--key { - text-style: bold; - background: $accent-darken-2; + text-style: bold; + background: $accent-darken-2; } """ @@ -65,7 +65,7 @@ class Footer(Widget): self.highlight_key = event.style.meta.get("key") async def on_leave(self, event: events.Leave) -> None: - """Clear any highlight when the mouse leave the widget""" + """Clear any highlight when the mouse leaves the widget""" self.highlight_key = None def __rich_repr__(self) -> rich.repr.Result: diff --git a/src/textual/widgets/_input.py b/src/textual/widgets/_input.py index bf3db3725..ef8bb88cc 100644 --- a/src/textual/widgets/_input.py +++ b/src/textual/widgets/_input.py @@ -56,7 +56,7 @@ class Input(Widget, can_focus=True): DEFAULT_CSS = """ Input { background: $boost; - color: $text; + color: $text; padding: 0 2; border: tall $background; width: 100%; @@ -82,9 +82,9 @@ class Input(Widget, can_focus=True): Binding("left", "cursor_left", "cursor left"), Binding("right", "cursor_right", "cursor right"), Binding("backspace", "delete_left", "delete left"), - Binding("home", "home", "Home"), - Binding("end", "end", "Home"), - Binding("ctrl+d", "delete_right", "Delete"), + Binding("home", "home", "home"), + Binding("end", "end", "end"), + Binding("ctrl+d", "delete_right", "delete right"), ] COMPONENT_CLASSES = {"input--cursor", "input--placeholder"} From 14af7be6fd6a58ef8b647809097fc05e9b9977ac Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 4 Oct 2022 11:43:30 +0100 Subject: [PATCH 2/8] Document Header widget --- docs/examples/widgets/header.py | 12 ++++++++++++ docs/reference/header.md | 1 + docs/widgets/footer.md | 2 +- docs/widgets/header.md | 33 +++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 docs/examples/widgets/header.py create mode 100644 docs/reference/header.md diff --git a/docs/examples/widgets/header.py b/docs/examples/widgets/header.py new file mode 100644 index 000000000..d6617101a --- /dev/null +++ b/docs/examples/widgets/header.py @@ -0,0 +1,12 @@ +from textual.app import App, ComposeResult +from textual.widgets import Header + + +class HeaderApp(App): + def compose(self) -> ComposeResult: + yield Header() + + +if __name__ == "__main__": + app = HeaderApp() + app.run() diff --git a/docs/reference/header.md b/docs/reference/header.md new file mode 100644 index 000000000..e6cfc0e44 --- /dev/null +++ b/docs/reference/header.md @@ -0,0 +1 @@ +::: textual.widgets.Header diff --git a/docs/widgets/footer.md b/docs/widgets/footer.md index 788c8e8ab..55a9e1fa8 100644 --- a/docs/widgets/footer.md +++ b/docs/widgets/footer.md @@ -15,7 +15,7 @@ widget. Notice how the `Footer` automatically displays the keybind. ```{.textual path="docs/examples/widgets/footer.py"} ``` -=== "button.py" +=== "footer.py" ```python --8<-- "docs/examples/widgets/footer.py" diff --git a/docs/widgets/header.md b/docs/widgets/header.md index 6c67b6a97..240d2dd52 100644 --- a/docs/widgets/header.md +++ b/docs/widgets/header.md @@ -1 +1,34 @@ # Header + +## Description + +A simple header widget which docks itself to the top of the parent container. + +## Example + +The example below shows an app with a `Header`. + +=== "Output" + + ```{.textual path="docs/examples/widgets/header.py"} + ``` + +=== "header.py" + + ```python + --8<-- "docs/examples/widgets/header.py" + ``` + +## Reactive Attributes + +| Name | Type | Default | Description | +|--------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `tall` | `bool` | `True` | Whether the `Header` widget is displayed as tall or not. The tall variant is 3 cells tall by default. The non-tall variant is a single cell tall. This can be toggled by clicking on the header. | + +## Messages + +This widget sends no messages. + +## See Also + +* [Header](../reference/header.md) code reference diff --git a/mkdocs.yml b/mkdocs.yml index f0f47ce7e..4ef376f2c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -102,6 +102,7 @@ nav: - "reference/events.md" - "reference/footer.md" - "reference/geometry.md" + - "reference/header.md" - "reference/index.md" - "reference/message_pump.md" - "reference/message.md" From 48ae4c87b1c389c0e32a07a4e0b039cac85fe727 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 4 Oct 2022 12:04:59 +0100 Subject: [PATCH 3/8] Add short docstring to Footer --- src/textual/widgets/_footer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/textual/widgets/_footer.py b/src/textual/widgets/_footer.py index 26534a4e9..e012b96fa 100644 --- a/src/textual/widgets/_footer.py +++ b/src/textual/widgets/_footer.py @@ -12,6 +12,7 @@ from ..widget import Widget @rich.repr.auto class Footer(Widget): + """A simple header widget which docks itself to the top of the parent container.""" DEFAULT_CSS = """ Footer { From 8225b43ac173cbd364f7cdce8e75fd977ccea2e7 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 4 Oct 2022 13:35:56 +0100 Subject: [PATCH 4/8] Document Static widget --- docs/examples/widgets/static.py | 12 ++++++++++++ docs/widgets/static.md | 32 ++++++++++++++++++++++++++++++++ src/textual/widgets/_static.py | 5 +++-- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 docs/examples/widgets/static.py diff --git a/docs/examples/widgets/static.py b/docs/examples/widgets/static.py new file mode 100644 index 000000000..691334e4a --- /dev/null +++ b/docs/examples/widgets/static.py @@ -0,0 +1,12 @@ +from textual.app import App, ComposeResult +from textual.widgets import Static + + +class StaticApp(App): + def compose(self) -> ComposeResult: + yield Static("Hello, world!") + + +if __name__ == "__main__": + app = StaticApp() + app.run() diff --git a/docs/widgets/static.md b/docs/widgets/static.md index 0be60b558..e37d96110 100644 --- a/docs/widgets/static.md +++ b/docs/widgets/static.md @@ -1 +1,33 @@ # Static + +## Description + +A widget which displays a static renderable content. +Can be used for simple text labels, but can also contain more complex Rich renderables. + +## Example + +The example below shows how you can use a `Static` widget as a simple text label. + +=== "Output" + + ```{.textual path="docs/examples/widgets/static.py"} + ``` + +=== "static.py" + + ```python + --8<-- "docs/examples/widgets/static.py" + ``` + +## Reactive Attributes + +This widget has no reactive attributes. + +## Messages + +This widget sends no messages. + +## See Also + +* [Static](../reference/static.md) code reference diff --git a/src/textual/widgets/_static.py b/src/textual/widgets/_static.py index 7e10a8a1b..3b91969ef 100644 --- a/src/textual/widgets/_static.py +++ b/src/textual/widgets/_static.py @@ -25,13 +25,14 @@ def _check_renderable(renderable: object): class Static(Widget): - """A widget to display simple static content, or use as a base- lass for more complex widgets. + """A widget to display simple static content, or use as a base class for more complex widgets. Args: renderable (RenderableType, optional): A Rich renderable, or string containing console markup. Defaults to "". expand (bool, optional): Rich renderable may expand beyond optimal. Defaults to False. - shrink (bool, optional): Rich renderable may shrink below optional. Defaults to False. + shrink (bool, optional): Rich renderable may shrink below optimal. Defaults to False. + markup (bool, optional): True if markup should be parsed and rendered. Defaults to True. name (str | None, optional): Name of widget. Defaults to None. id (str | None, optional): ID of Widget. Defaults to None. classes (str | None, optional): Space separated list of class names. Defaults to None. From ad610e61cd1cea83bfe7a19cc047579510f40762 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 4 Oct 2022 15:30:53 +0100 Subject: [PATCH 5/8] Example app showing input --- docs/examples/widgets/input.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docs/examples/widgets/input.py diff --git a/docs/examples/widgets/input.py b/docs/examples/widgets/input.py new file mode 100644 index 000000000..3b315c571 --- /dev/null +++ b/docs/examples/widgets/input.py @@ -0,0 +1,13 @@ +from textual.app import App, ComposeResult +from textual.widgets import Input + + +class InputApp(App): + def compose(self) -> ComposeResult: + yield Input(placeholder="First Name") + yield Input(placeholder="Last Name") + + +if __name__ == "__main__": + app = InputApp() + app.run() From ce58e3e3e362737a347163d7d7e6bf783a6f9c6d Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 4 Oct 2022 17:05:57 +0100 Subject: [PATCH 6/8] More documentation for Input widget --- docs/events/click.md | 2 +- docs/events/mouse_move.md | 2 +- docs/events/mouse_release.md | 2 +- docs/events/mouse_scroll_down.md | 2 +- docs/events/mouse_scroll_up.md | 2 +- docs/events/mouse_up.md | 2 +- docs/events/paste.md | 2 +- docs/events/resize.md | 2 +- docs/reference/input.md | 1 + docs/widgets/footer.md | 3 ++ docs/widgets/header.md | 3 ++ docs/widgets/input.md | 68 ++++++++++++++++++++++++++++++++ docs/widgets/static.md | 3 ++ docs/widgets/text_input.md | 1 - mkdocs.yml | 2 +- 15 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 docs/reference/input.md create mode 100644 docs/widgets/input.md delete mode 100644 docs/widgets/text_input.md diff --git a/docs/events/click.md b/docs/events/click.md index 5d1c80c68..8be36002f 100644 --- a/docs/events/click.md +++ b/docs/events/click.md @@ -8,7 +8,7 @@ The `Click` event is sent to a widget when the user clicks a mouse button. ## Attributes | attribute | type | purpose | -| ---------- | ---- | ----------------------------------------- | +|------------|------|-------------------------------------------| | `x` | int | Mouse x coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget | | `delta_x` | int | Change in x since last mouse event | diff --git a/docs/events/mouse_move.md b/docs/events/mouse_move.md index 42fb61389..12cdca5f9 100644 --- a/docs/events/mouse_move.md +++ b/docs/events/mouse_move.md @@ -8,7 +8,7 @@ The `MouseMove` event is sent to a widget when the mouse pointer is moved over a ## Attributes | attribute | type | purpose | -| ---------- | ---- | ----------------------------------------- | +|------------|------|-------------------------------------------| | `x` | int | Mouse x coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget | | `delta_x` | int | Change in x since last mouse event | diff --git a/docs/events/mouse_release.md b/docs/events/mouse_release.md index 5d0fb1eba..89d1fe4ed 100644 --- a/docs/events/mouse_release.md +++ b/docs/events/mouse_release.md @@ -8,7 +8,7 @@ The `MouseRelease` event is sent to a widget when it is no longer receiving mous ## Attributes | attribute | type | purpose | -| ---------------- | ------ | --------------------------------------------- | +|------------------|--------|-----------------------------------------------| | `mouse_position` | Offset | Mouse coordinates when the mouse was released | ## Code diff --git a/docs/events/mouse_scroll_down.md b/docs/events/mouse_scroll_down.md index 2808cbf24..7228cc0bb 100644 --- a/docs/events/mouse_scroll_down.md +++ b/docs/events/mouse_scroll_down.md @@ -8,7 +8,7 @@ The `MouseScrollDown` event is sent to a widget when the scroll wheel (or trackp ## Attributes | attribute | type | purpose | -| --------- | ---- | -------------------------------------- | +|-----------|------|----------------------------------------| | `x` | int | Mouse x coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget | diff --git a/docs/events/mouse_scroll_up.md b/docs/events/mouse_scroll_up.md index 8fbe19c78..2114b5f41 100644 --- a/docs/events/mouse_scroll_up.md +++ b/docs/events/mouse_scroll_up.md @@ -8,7 +8,7 @@ The `MouseScrollUp` event is sent to a widget when the scroll wheel (or trackpad ## Attributes | attribute | type | purpose | -| --------- | ---- | -------------------------------------- | +|-----------|------|----------------------------------------| | `x` | int | Mouse x coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget | diff --git a/docs/events/mouse_up.md b/docs/events/mouse_up.md index 9536089ed..5b965132e 100644 --- a/docs/events/mouse_up.md +++ b/docs/events/mouse_up.md @@ -8,7 +8,7 @@ The `MouseUp` event is sent to a widget when the user releases a mouse button. ## Attributes | attribute | type | purpose | -| ---------- | ---- | ----------------------------------------- | +|------------|------|-------------------------------------------| | `x` | int | Mouse x coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget | | `delta_x` | int | Change in x since last mouse event | diff --git a/docs/events/paste.md b/docs/events/paste.md index c9e051271..fdae43e5c 100644 --- a/docs/events/paste.md +++ b/docs/events/paste.md @@ -8,7 +8,7 @@ The `Paste` event is sent to a widget when the user pastes text. ## Attributes | attribute | type | purpose | -| --------- | ---- | ------------------------ | +|-----------|------|--------------------------| | `text` | str | The text that was pasted | ## Code diff --git a/docs/events/resize.md b/docs/events/resize.md index 87e0ae8ac..2ffe554af 100644 --- a/docs/events/resize.md +++ b/docs/events/resize.md @@ -8,7 +8,7 @@ The `Resize` event is sent to a widget when its size changes and when it is firs ## Attributes | attribute | type | purpose | -| ---------------- | ---- | ------------------------------------------------ | +|------------------|------|--------------------------------------------------| | `size` | Size | The new size of the Widget | | `virtual_size` | Size | The virtual size (scrollable area) of the Widget | | `container_size` | Size | The size of the container (parent widget) | diff --git a/docs/reference/input.md b/docs/reference/input.md new file mode 100644 index 000000000..259ea86f9 --- /dev/null +++ b/docs/reference/input.md @@ -0,0 +1 @@ +::: textual.widgets.Input diff --git a/docs/widgets/footer.md b/docs/widgets/footer.md index 55a9e1fa8..c733decb1 100644 --- a/docs/widgets/footer.md +++ b/docs/widgets/footer.md @@ -5,6 +5,9 @@ A simple footer widget which is docked to the bottom of its parent container. Displays available keybindings for the currently focused widget. +- [ ] Focusable +- [ ] Container + ## Example The example below shows an app with a single keybinding that contains only a `Footer` diff --git a/docs/widgets/header.md b/docs/widgets/header.md index 240d2dd52..b66e9f23c 100644 --- a/docs/widgets/header.md +++ b/docs/widgets/header.md @@ -4,6 +4,9 @@ A simple header widget which docks itself to the top of the parent container. +- [ ] Focusable +- [ ] Container + ## Example The example below shows an app with a `Header`. diff --git a/docs/widgets/input.md b/docs/widgets/input.md new file mode 100644 index 000000000..dde12dabf --- /dev/null +++ b/docs/widgets/input.md @@ -0,0 +1,68 @@ +# Input + +## Description + +A single-line text input widget. + +- [x] Focusable +- [ ] Container + +## Example + +The example below shows how you might create a simple form using two `Input` widgets. + +=== "Output" + + ```{.textual path="docs/examples/widgets/input.py"} + ``` + +=== "input.py" + + ```python + --8<-- "docs/examples/widgets/input.py" + ``` + +## Reactive Attributes + +| Name | Type | Default | Description | +|-------------------|--------|---------|-----------------------------------------------------------------| +| `cursor_blink` | `bool` | `True` | True if cursor blinking is enabled. | +| `value` | `str` | `""` | The value currently in the text input. | +| `cursor_position` | `int` | `0` | The index of the cursor in the value string. | +| `placeholder` | `str` | `str` | The dimmed placeholder text to display when the input is empty. | +| `password` | `bool` | `False` | True if the input should be masked. | + +## Messages + +### Changed + +The `Input.Changed` message is sent when the value in the text input changes. + +- [x] Bubbles + +#### Attributes + +| attribute | type | purpose | +|-----------|-------|----------------------------------| +| `value` | `str` | The new value in the text input. | + + +### Submitted + +- [x] Bubbles + +#### Attributes + +| attribute | type | purpose | +|-----------|-------|----------------------------------| +| `value` | `str` | The new value in the text input. | + + +## Additional Notes + +* The spacing around the text content is due to border. To remove it, set `border: none;` in your CSS. +* + +## See Also + +* [Input](../reference/input.md) code reference diff --git a/docs/widgets/static.md b/docs/widgets/static.md index e37d96110..27121bda7 100644 --- a/docs/widgets/static.md +++ b/docs/widgets/static.md @@ -5,6 +5,9 @@ A widget which displays a static renderable content. Can be used for simple text labels, but can also contain more complex Rich renderables. +- [ ] Focusable +- [x] Container + ## Example The example below shows how you can use a `Static` widget as a simple text label. diff --git a/docs/widgets/text_input.md b/docs/widgets/text_input.md deleted file mode 100644 index c55ce3dde..000000000 --- a/docs/widgets/text_input.md +++ /dev/null @@ -1 +0,0 @@ -# TextInput diff --git a/mkdocs.yml b/mkdocs.yml index 4ef376f2c..86e691c1d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -91,7 +91,7 @@ nav: - "widgets/footer.md" - "widgets/header.md" - "widgets/static.md" - - "widgets/text_input.md" + - "widgets/input.md" - "widgets/tree_control.md" - Reference: - "reference/app.md" From d98d889dd152772525fe71c34157b800fac7300a Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 4 Oct 2022 17:26:36 +0100 Subject: [PATCH 7/8] Add note on Input.Submitted docs --- docs/widgets/input.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/widgets/input.md b/docs/widgets/input.md index dde12dabf..9c3580633 100644 --- a/docs/widgets/input.md +++ b/docs/widgets/input.md @@ -49,6 +49,8 @@ The `Input.Changed` message is sent when the value in the text input changes. ### Submitted +The `Input.Submitted` message is sent when you press ++enter++ with the text field submitted. + - [x] Bubbles #### Attributes @@ -61,7 +63,6 @@ The `Input.Changed` message is sent when the value in the text input changes. ## Additional Notes * The spacing around the text content is due to border. To remove it, set `border: none;` in your CSS. -* ## See Also From b246278233549a0c52157758bafbc7cf0c6cd05e Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Wed, 5 Oct 2022 09:26:39 +0100 Subject: [PATCH 8/8] tweaks and fixes --- docs/widgets/button.md | 3 +-- docs/widgets/footer.md | 4 +--- docs/widgets/header.md | 4 +--- docs/widgets/input.md | 10 ++++------ docs/widgets/static.md | 4 +--- mkdocs.yml | 1 - 6 files changed, 8 insertions(+), 18 deletions(-) diff --git a/docs/widgets/button.md b/docs/widgets/button.md index 2b1008e85..1387ffdf2 100644 --- a/docs/widgets/button.md +++ b/docs/widgets/button.md @@ -1,6 +1,5 @@ # Button -## Description A simple button widget which can be pressed using a mouse click or by pressing ++return++ when it has focus. @@ -33,7 +32,7 @@ Clicking any of the non-disabled buttons in the example app below will result in ## Reactive Attributes | Name | Type | Default | Description | -|------------|--------|-------------|-----------------------------------------------------------------------------------------------------------------------------------| +| ---------- | ------ | ----------- | --------------------------------------------------------------------------------------------------------------------------------- | | `label` | `str` | `""` | The text that appears inside the button. | | `variant` | `str` | `"default"` | Semantic styling variant. One of `default`, `primary`, `success`, `warning`, `error`. | | `disabled` | `bool` | `False` | Whether the button is disabled or not. Disabled buttons cannot be focused or clicked, and are styled in a way that suggests this. | diff --git a/docs/widgets/footer.md b/docs/widgets/footer.md index c733decb1..01717b225 100644 --- a/docs/widgets/footer.md +++ b/docs/widgets/footer.md @@ -1,7 +1,5 @@ # Footer -## Description - A simple footer widget which is docked to the bottom of its parent container. Displays available keybindings for the currently focused widget. @@ -27,7 +25,7 @@ widget. Notice how the `Footer` automatically displays the keybind. ## Reactive Attributes | Name | Type | Default | Description | -|-----------------|-------|---------|-----------------------------------------------------------------------------------------------------------| +| --------------- | ----- | ------- | --------------------------------------------------------------------------------------------------------- | | `highlight_key` | `str` | `None` | Stores the currently highlighted key. This is typically the key the cursor is hovered over in the footer. | ## Messages diff --git a/docs/widgets/header.md b/docs/widgets/header.md index b66e9f23c..685ce04ee 100644 --- a/docs/widgets/header.md +++ b/docs/widgets/header.md @@ -1,7 +1,5 @@ # Header -## Description - A simple header widget which docks itself to the top of the parent container. - [ ] Focusable @@ -25,7 +23,7 @@ The example below shows an app with a `Header`. ## Reactive Attributes | Name | Type | Default | Description | -|--------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| ------ | ------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `tall` | `bool` | `True` | Whether the `Header` widget is displayed as tall or not. The tall variant is 3 cells tall by default. The non-tall variant is a single cell tall. This can be toggled by clicking on the header. | ## Messages diff --git a/docs/widgets/input.md b/docs/widgets/input.md index 9c3580633..e98d27b23 100644 --- a/docs/widgets/input.md +++ b/docs/widgets/input.md @@ -1,7 +1,5 @@ # Input -## Description - A single-line text input widget. - [x] Focusable @@ -13,7 +11,7 @@ The example below shows how you might create a simple form using two `Input` wid === "Output" - ```{.textual path="docs/examples/widgets/input.py"} + ```{.textual path="docs/examples/widgets/input.py" press="tab,D,a,r,r,e,n"} ``` === "input.py" @@ -25,7 +23,7 @@ The example below shows how you might create a simple form using two `Input` wid ## Reactive Attributes | Name | Type | Default | Description | -|-------------------|--------|---------|-----------------------------------------------------------------| +| ----------------- | ------ | ------- | --------------------------------------------------------------- | | `cursor_blink` | `bool` | `True` | True if cursor blinking is enabled. | | `value` | `str` | `""` | The value currently in the text input. | | `cursor_position` | `int` | `0` | The index of the cursor in the value string. | @@ -43,7 +41,7 @@ The `Input.Changed` message is sent when the value in the text input changes. #### Attributes | attribute | type | purpose | -|-----------|-------|----------------------------------| +| --------- | ----- | -------------------------------- | | `value` | `str` | The new value in the text input. | @@ -56,7 +54,7 @@ The `Input.Submitted` message is sent when you press ++enter++ with the text fie #### Attributes | attribute | type | purpose | -|-----------|-------|----------------------------------| +| --------- | ----- | -------------------------------- | | `value` | `str` | The new value in the text input. | diff --git a/docs/widgets/static.md b/docs/widgets/static.md index 27121bda7..3ed68ac95 100644 --- a/docs/widgets/static.md +++ b/docs/widgets/static.md @@ -1,8 +1,6 @@ # Static -## Description - -A widget which displays a static renderable content. +A widget which displays static content. Can be used for simple text labels, but can also contain more complex Rich renderables. - [ ] Focusable diff --git a/mkdocs.yml b/mkdocs.yml index 3db977e5c..31e891769 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -93,7 +93,6 @@ nav: - "widgets/index.md" - "widgets/input.md" - "widgets/static.md" - - "widgets/input.md" - "widgets/tree_control.md" - Reference: - "reference/app.md"