mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
docs
This commit is contained in:
27
docs/examples/styles/scrollbar_visibility.py
Normal file
27
docs/examples/styles/scrollbar_visibility.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from textual.app import App
|
||||||
|
from textual.containers import Horizontal, VerticalScroll
|
||||||
|
from textual.widgets import Label
|
||||||
|
|
||||||
|
TEXT = """I must not fear.
|
||||||
|
Fear is the mind-killer.
|
||||||
|
Fear is the little-death that brings total obliteration.
|
||||||
|
I will face my fear.
|
||||||
|
I will permit it to pass over me and through me.
|
||||||
|
And when it has gone past, I will turn the inner eye to see its path.
|
||||||
|
Where the fear has gone there will be nothing. Only I will remain.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class ScrollbarApp(App):
|
||||||
|
CSS_PATH = "scrollbar_visibility.tcss"
|
||||||
|
|
||||||
|
def compose(self):
|
||||||
|
yield Horizontal(
|
||||||
|
VerticalScroll(Label(TEXT * 10), classes="left"),
|
||||||
|
VerticalScroll(Label(TEXT * 10), classes="right"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = ScrollbarApp()
|
||||||
|
app.run()
|
||||||
11
docs/examples/styles/scrollbar_visibility.tcss
Normal file
11
docs/examples/styles/scrollbar_visibility.tcss
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
VerticalScroll {
|
||||||
|
width: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left {
|
||||||
|
scrollbar-visibility: visible; # The default
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
scrollbar-visibility: hidden;
|
||||||
|
}
|
||||||
60
docs/styles/scrollbar_visibility.md
Normal file
60
docs/styles/scrollbar_visibility.md
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# Scrollbar-visibility
|
||||||
|
|
||||||
|
The `scrollbar-visibility` is used to show or hide scrollbars.
|
||||||
|
|
||||||
|
If scrollbars are hidden, the user may still scroll the container using the mouse wheel / keys / and gestures, but
|
||||||
|
there will be no scrollbars shown.
|
||||||
|
|
||||||
|
## Syntax
|
||||||
|
|
||||||
|
--8<-- "docs/snippets/syntax_block_start.md"
|
||||||
|
scrollbar-visibility: hidden | visible;
|
||||||
|
--8<-- "docs/snippets/syntax_block_end.md"
|
||||||
|
|
||||||
|
|
||||||
|
### Values
|
||||||
|
|
||||||
|
| Value | Description |
|
||||||
|
| ------------------- | ---------------------------------------------------- |
|
||||||
|
| `hidden` | The widget's scrollbars will be hidden. |
|
||||||
|
| `visible` (default) | The widget's scrollbars will be displayed as normal. |
|
||||||
|
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
The following example contains two containers with the same text.
|
||||||
|
The container on the right has its scrollbar hidden.
|
||||||
|
|
||||||
|
=== "Output"
|
||||||
|
|
||||||
|
```{.textual path="docs/examples/styles/scrollbar_visibility.py"}
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "scrollbar_visibility.py"
|
||||||
|
|
||||||
|
```py
|
||||||
|
--8<-- "docs/examples/styles/scrollbar_visibility.py"
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "scrollbar_visibility.tcss"
|
||||||
|
|
||||||
|
```css
|
||||||
|
--8<-- "docs/examples/styles/scrollbar_visibility.tcss"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## CSS
|
||||||
|
|
||||||
|
```css
|
||||||
|
scrollbar-visibility: visible;
|
||||||
|
scrollbar-visibility: hidden;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Python
|
||||||
|
|
||||||
|
```py
|
||||||
|
widget.styles.scrollbar_visibility = "visible";
|
||||||
|
widget.styles.scrollbar_visibility = "hidden";
|
||||||
|
```
|
||||||
@@ -136,6 +136,7 @@ nav:
|
|||||||
- "styles/scrollbar_colors/scrollbar_corner_color.md"
|
- "styles/scrollbar_colors/scrollbar_corner_color.md"
|
||||||
- "styles/scrollbar_gutter.md"
|
- "styles/scrollbar_gutter.md"
|
||||||
- "styles/scrollbar_size.md"
|
- "styles/scrollbar_size.md"
|
||||||
|
- "styles/scrollbar_visibility.md"
|
||||||
- "styles/text_align.md"
|
- "styles/text_align.md"
|
||||||
- "styles/text_opacity.md"
|
- "styles/text_opacity.md"
|
||||||
- "styles/text_overflow.md"
|
- "styles/text_overflow.md"
|
||||||
|
|||||||
@@ -3421,7 +3421,6 @@ class Widget(DOMNode):
|
|||||||
`True` if any scrolling has occurred in any descendant, otherwise `False`.
|
`True` if any scrolling has occurred in any descendant, otherwise `False`.
|
||||||
"""
|
"""
|
||||||
# Grow the region by the margin so to keep the margin in view.
|
# Grow the region by the margin so to keep the margin in view.
|
||||||
|
|
||||||
region = widget.virtual_region_with_margin
|
region = widget.virtual_region_with_margin
|
||||||
scrolled = False
|
scrolled = False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user