File: digits.md

package info (click to toggle)
textual 2.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 55,056 kB
  • sloc: python: 85,423; lisp: 1,669; makefile: 101
file content (70 lines) | stat: -rw-r--r-- 1,301 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Digits

!!! tip "Added in version 0.33.0"

A widget to display numerical values in tall multi-line characters.

The digits 0-9 and characters A-F are supported, in addition to `+`, `-`, `^`, `:`, and `×`.
Other characters will be displayed in a regular size font.

You can set the text to be displayed in the constructor, or call [`update()`][textual.widgets.Digits.update] to change the text after the widget has been mounted.

!!! note "This widget will respect the [text-align](../styles/text_align.md) rule."

- [ ] Focusable
- [ ] Container


## Example

The following example displays a few digits of Pi:

=== "Output"

    ```{.textual path="docs/examples/widgets/digits.py"}
    ```

=== "digits.py"

    ```python
    --8<-- "docs/examples/widgets/digits.py"
    ```

Here's another example which uses `Digits` to display the current time:


=== "Output"

    ```{.textual path="docs/examples/widgets/clock.py"}
    ```

=== "clock.py"

    ```python
    --8<-- "docs/examples/widgets/clock.py"
    ```

## Reactive Attributes

This widget has no reactive attributes.

## Messages

This widget posts no messages.

## Bindings

This widget has no bindings.

## Component Classes

This widget has no component classes.



---


::: textual.widgets.Digits
    options:
      heading_level: 2