File: _cursor_tracking.py

package info (click to toggle)
textual-autocomplete 4.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 796 kB
  • sloc: python: 1,907; makefile: 4
file content (39 lines) | stat: -rw-r--r-- 985 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from textual_autocomplete._autocomplete import AutoComplete
from textual.app import App, ComposeResult
from textual.containers import Center, VerticalScroll
from textual.widgets import Input


class CursorTracking(App[None]):
    CSS = """
    #scrollable {
        overflow: scroll scroll;
        scrollbar-color: red;
        Center {
            background: $accent;
            height: 100;
            width: 100;
            align-vertical: middle;
        }
        Input {
            width: 24;
        }
    }
    """

    def compose(self) -> ComposeResult:
        with VerticalScroll(id="scrollable", can_focus=False):
            with Center():
                input = Input(placeholder="Type here...")
                input.cursor_blink = False
                yield input

        yield AutoComplete(
            target=input,
            candidates=["foo", "bar", "baz", "qux", "boop"],
        )


if __name__ == "__main__":
    app = CursorTracking()
    app.run()