flexablelib 3.6.0__tar.gz → 3.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flexablelib-3.6.0 → flexablelib-3.7.1}/CHANGELOG.md +66 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/PKG-INFO +12 -9
- {flexablelib-3.6.0 → flexablelib-3.7.1}/README.md +3 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/_images.py +23 -7
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib.egg-info/PKG-INFO +12 -9
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib.egg-info/SOURCES.txt +2 -0
- flexablelib-3.7.1/flexablelib.egg-info/requires.txt +35 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/package.json +1 -1
- flexablelib-3.7.1/tests/test_v370_features.py +296 -0
- flexablelib-3.7.1/tests/test_v371_fixes.py +509 -0
- flexablelib-3.6.0/flexablelib.egg-info/requires.txt +0 -35
- {flexablelib-3.6.0 → flexablelib-3.7.1}/.coveragerc +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/LICENSE +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/MANIFEST.in +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/examples/admin.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/examples/dashboard.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/examples/keys.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/examples/video/demo.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/examples/video/render.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/examples/video/scenes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/examples/video/thumbnail.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/__init__.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/_frames.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/_legacy/__init__.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/_legacy/screen.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/_legacy/widgets.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/_speedups.c +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/_width_tables.h +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/box_topology.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/cells.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/colors.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/columns.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/fast.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/identifiers.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/layout.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/merges.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/options.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/py.typed +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/readers.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/screen.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/style_compositions.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/table.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/table_strings.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/text_width.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/utils.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/widgets.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib/writers.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib.egg-info/dependency_links.txt +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/flexablelib.egg-info/top_level.txt +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/pytest.ini +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/setup.cfg +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/setup.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/style_examples.md +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/conftest.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/helpers.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_align_indicators.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_box_topology.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_cells.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_columns.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_excel.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_features.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_issues.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_merge_edge_matrix.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_merge_fill.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_merges.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_public_api_edges.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_readme_examples.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_stress_matrix.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_style_line_widths.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_styles.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_text_width.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_two_pass_measurement.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_upstream_issues.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v2021_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v210_rows_copy.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v2110_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v211_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v213_features.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v214_features.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v215_features.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v216_features.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v217_features.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v218_features.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v219_coverage.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v219_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v220_exports.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v221_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v222_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v223_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v224_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v230_none.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v231_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v232_merge_ansi.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v300_style_names.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v310_layout.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v320_tui.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v330_components.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v330_frames.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v330_layout.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v330_tui.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v331_formats.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v331_panel_width.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v331_readers_bom.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v331_readers_edges.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v331_tabs.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v340_accessibility.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v340_core.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v340_input.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v350_images.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v350_images_core.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v352_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v353_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v354_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v355_fixes.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/test_v360_features.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tests/wincon_child.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/bench_frames.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/bench_images.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/benchmark.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/gen_ascii_table.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/generate_width_tables.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/image_demo.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/pty_check.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/readme_gallery.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/stress_matrix.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/style_examples.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/text_to_png.py +0 -0
- {flexablelib-3.6.0 → flexablelib-3.7.1}/tools/wheel_check.py +0 -0
|
@@ -2,6 +2,72 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [3.7.1] - 2026-11-16
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **`Form` at narrow widths**: with `columns` (or a tuple row) wider than
|
|
9
|
+
the form, drawing raised `ValueError: width must be >= 1`; fields that
|
|
10
|
+
do not get a cell each now stack below, and `grid_columns(width)` never
|
|
11
|
+
gives more columns than get one cell.
|
|
12
|
+
- **`CatalogGrid`** with `card_height` under 3 (0 divided by zero when a
|
|
13
|
+
height was given) or `min_width` under 1 (-1 divided by zero): a card
|
|
14
|
+
keeps its border and a line inside.
|
|
15
|
+
- **`SignatureInput`**: erasing (`x` / Delete) with the pen down and then
|
|
16
|
+
moving joined what was left of the drawing to the pen with a line nobody
|
|
17
|
+
drew; erasing now lifts the pen. `value` is a copy, so what a `Form`
|
|
18
|
+
collected (or `on_change` got) no longer changes as the user keeps
|
|
19
|
+
drawing.
|
|
20
|
+
- **`Stopwatch`** numbers its laps by lap also when `max_laps` dropped the
|
|
21
|
+
first ones (laps 8-10 were shown as 1-3).
|
|
22
|
+
- **`Menu` / `Sidebar`**: a `max_visible` larger than the height they are
|
|
23
|
+
drawn in hid the current item (the window was cut at the bottom); a
|
|
24
|
+
sidebar too short for its title and an item keeps the item.
|
|
25
|
+
- **`VStack`**: when the child holding the focus is taller than the view,
|
|
26
|
+
the focused component inside it is scrolled into view, not the child's
|
|
27
|
+
first rows; a `height` larger than the slot keeps to the slot (it was
|
|
28
|
+
cut off, losing the focus); a growing child left without rows keeps one
|
|
29
|
+
instead of vanishing while Tab could still land on it.
|
|
30
|
+
- **`DataTable`** with a `page_size` taller than its slot scrolls inside
|
|
31
|
+
the page, so the cursor row stays in view (it could be cut off).
|
|
32
|
+
- **`StatusLine`** stays on one line: line breaks and tabs in its parts
|
|
33
|
+
become spaces (a newline drew a second line). A long left text now gives
|
|
34
|
+
way (`…`) so the right one stays in view.
|
|
35
|
+
- **Image downloads with headers**: an invalid header value (a token with a
|
|
36
|
+
line break) was quoted in the error text shown on screen; now the error
|
|
37
|
+
says `cabecera no válida`, never the value, and the original exception
|
|
38
|
+
is not chained. Spaces and a trailing newline around header values (a
|
|
39
|
+
token read from a file) are trimmed.
|
|
40
|
+
|
|
41
|
+
## [3.7.0] - 2026-11-13
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
- **`ScrollView` follows the focus** (`follow_focus=True`, the default):
|
|
45
|
+
when a component inside it takes the focus, its rows are scrolled into
|
|
46
|
+
view; scrolling by hand afterwards is left alone. `focus_rows(width)`
|
|
47
|
+
gives the rows of the focused component.
|
|
48
|
+
- **`Menu` and `Sidebar` keep to their height**: with more items than fit,
|
|
49
|
+
a window around the current item with `▲ n más` / `▼ n más` lines (click
|
|
50
|
+
them to page); PgUp/PgDn move a page and the wheel scrolls. The sidebar
|
|
51
|
+
title stays on top.
|
|
52
|
+
- **Responsive `Form` grid**: `min_column_width` drops to fewer columns when
|
|
53
|
+
they would be narrower; `FormCell(field, span=, min_width=)` and
|
|
54
|
+
`Form.set_layout()` give a field several columns, more when it would be
|
|
55
|
+
narrower than its minimum; `grid_columns(width)`.
|
|
56
|
+
- **`DataTable(fill=True)`** takes its whole slot with the status line at
|
|
57
|
+
the bottom; `visible_rows` is how many rows the last frame showed.
|
|
58
|
+
- **`GridView`**: a `flexablelib.Grid` as a component with an accessible
|
|
59
|
+
name (`title` / `a11y_label`) and role, and `audit()` for itself and
|
|
60
|
+
every component inside.
|
|
61
|
+
- **`StatusLine`**: a one-line status bar with role `status`, a symbol per
|
|
62
|
+
kind besides the colour, and screen-reader announcements on change.
|
|
63
|
+
|
|
64
|
+
### Changed
|
|
65
|
+
- **`VStack` without `weights`** gives weight 1 to children that fill their
|
|
66
|
+
slot (`expand`: `DataTable(fill=True)`, `ScrollView`, `Sidebar`, `Tabs`),
|
|
67
|
+
so they share the rows left over; before, every child kept its own
|
|
68
|
+
height.
|
|
69
|
+
- `Menu` with `max_visible` (or a height) now shows the `▲` / `▼` lines.
|
|
70
|
+
|
|
5
71
|
## [3.6.0] - 2026-11-13
|
|
6
72
|
|
|
7
73
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.7.1
|
|
4
4
|
Summary: Fast, dependency-free terminal tables for Python: 54 border styles, ANSI colors, cell merges, decimal alignment, width fitting, and CSV/Markdown/HTML/Excel/LaTeX I/O.
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -46,15 +46,15 @@ Requires-Dist: openpyxl>=3.0; extra == "excel"
|
|
|
46
46
|
Provides-Extra: html
|
|
47
47
|
Requires-Dist: lxml>=4.0; extra == "html"
|
|
48
48
|
Provides-Extra: tui
|
|
49
|
-
Requires-Dist: flexablelib-tui==3.
|
|
49
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "tui"
|
|
50
50
|
Provides-Extra: components
|
|
51
|
-
Requires-Dist: flexablelib-components==3.
|
|
51
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "components"
|
|
52
52
|
Provides-Extra: speed
|
|
53
|
-
Requires-Dist: flexablelib-speedups==3.
|
|
53
|
+
Requires-Dist: flexablelib-speedups==3.7.1; extra == "speed"
|
|
54
54
|
Provides-Extra: images
|
|
55
55
|
Requires-Dist: Pillow>=8; extra == "images"
|
|
56
|
-
Requires-Dist: flexablelib-tui==3.
|
|
57
|
-
Requires-Dist: flexablelib-components==3.
|
|
56
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "images"
|
|
57
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "images"
|
|
58
58
|
Provides-Extra: svg
|
|
59
59
|
Requires-Dist: cairosvg>=2.5; extra == "svg"
|
|
60
60
|
Provides-Extra: all
|
|
@@ -62,9 +62,9 @@ Requires-Dist: pandas>=1.0; extra == "all"
|
|
|
62
62
|
Requires-Dist: openpyxl>=3.0; extra == "all"
|
|
63
63
|
Requires-Dist: lxml>=4.0; extra == "all"
|
|
64
64
|
Requires-Dist: Pillow>=8; extra == "all"
|
|
65
|
-
Requires-Dist: flexablelib-tui==3.
|
|
66
|
-
Requires-Dist: flexablelib-components==3.
|
|
67
|
-
Requires-Dist: flexablelib-speedups==3.
|
|
65
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "all"
|
|
66
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "all"
|
|
67
|
+
Requires-Dist: flexablelib-speedups==3.7.1; extra == "all"
|
|
68
68
|
Dynamic: author
|
|
69
69
|
Dynamic: author-email
|
|
70
70
|
Dynamic: classifier
|
|
@@ -189,6 +189,9 @@ in colour or plain text: the full list, what each does and its keys is in
|
|
|
189
189
|
<tr>
|
|
190
190
|
<td colspan="2"><b>New in 3.6.0</b> — signature pad, stopwatch, a vertical stack that shares its height and follows the focus, focus shown without colour, forms that collect nested fields and editable tables, scanners that keep the code read, catalog cards with pictures, pictures downloaded with an <code>Authorization</code> header, a validation summary from a list of errors<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v36/01_novedades.png" alt="3.6.0 components: SignatureInput, Stopwatch, VStack, focus markers, ScanInput, CatalogGrid with images, ValidationSummary" width="520"></td>
|
|
191
191
|
</tr>
|
|
192
|
+
<tr>
|
|
193
|
+
<td colspan="2"><b>New in 3.7.0</b> — scroll views that follow the focus, menus and sidebars that keep to their height, responsive form columns with spans, tables that fill their slot, an accessible grid with its own audit, a status line for screen readers<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v36/02_novedades_370.png" alt="3.7.0 components: ScrollView following the focus, Menu and Sidebar windows, Form grid, DataTable fill, GridView, StatusLine" width="520"></td>
|
|
194
|
+
</tr>
|
|
192
195
|
</table>
|
|
193
196
|
|
|
194
197
|
### Keyboard, mouse and accessibility
|
|
@@ -108,6 +108,9 @@ in colour or plain text: the full list, what each does and its keys is in
|
|
|
108
108
|
<tr>
|
|
109
109
|
<td colspan="2"><b>New in 3.6.0</b> — signature pad, stopwatch, a vertical stack that shares its height and follows the focus, focus shown without colour, forms that collect nested fields and editable tables, scanners that keep the code read, catalog cards with pictures, pictures downloaded with an <code>Authorization</code> header, a validation summary from a list of errors<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v36/01_novedades.png" alt="3.6.0 components: SignatureInput, Stopwatch, VStack, focus markers, ScanInput, CatalogGrid with images, ValidationSummary" width="520"></td>
|
|
110
110
|
</tr>
|
|
111
|
+
<tr>
|
|
112
|
+
<td colspan="2"><b>New in 3.7.0</b> — scroll views that follow the focus, menus and sidebars that keep to their height, responsive form columns with spans, tables that fill their slot, an accessible grid with its own audit, a status line for screen readers<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v36/02_novedades_370.png" alt="3.7.0 components: ScrollView following the focus, Menu and Sidebar windows, Form grid, DataTable fill, GridView, StatusLine" width="520"></td>
|
|
113
|
+
</tr>
|
|
111
114
|
</table>
|
|
112
115
|
|
|
113
116
|
### Keyboard, mouse and accessibility
|
|
@@ -750,22 +750,38 @@ def read_source(source, timeout=5.0, max_bytes=64 * 1024 * 1024,
|
|
|
750
750
|
return source.read(), getattr(source, 'name', None)
|
|
751
751
|
path = os.fspath(source)
|
|
752
752
|
if path.startswith(('http://', 'https://')):
|
|
753
|
+
from http.client import InvalidURL
|
|
754
|
+
from urllib.error import URLError
|
|
753
755
|
from urllib.request import Request, urlopen
|
|
754
756
|
try:
|
|
755
757
|
req = Request(path, headers={'User-Agent': 'flexablelib'})
|
|
756
758
|
for name, value in (headers or {}).items():
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
759
|
+
# A token read from a file keeps its newline: HTTP trims
|
|
760
|
+
# the spaces around a value anyway.
|
|
761
|
+
name, value = str(name).strip(), str(value).strip()
|
|
762
|
+
if name.lower() in _PRIVATE_HEADERS:
|
|
763
|
+
req.add_unredirected_header(name.capitalize(), value)
|
|
760
764
|
else:
|
|
761
|
-
req.add_header(
|
|
765
|
+
req.add_header(name, value)
|
|
762
766
|
with urlopen(req, timeout=timeout) as resp:
|
|
763
767
|
data = resp.read(max_bytes + 1)
|
|
764
768
|
except Exception as error:
|
|
765
769
|
code = getattr(error, 'code', None)
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
770
|
+
if isinstance(code, int):
|
|
771
|
+
reason = 'HTTP {0}'.format(code)
|
|
772
|
+
elif isinstance(error, URLError):
|
|
773
|
+
reason = error.reason
|
|
774
|
+
elif isinstance(error, InvalidURL):
|
|
775
|
+
reason = 'URL no válida'
|
|
776
|
+
elif isinstance(error, OSError):
|
|
777
|
+
reason = str(error) or type(error).__name__
|
|
778
|
+
elif isinstance(error, ValueError):
|
|
779
|
+
# http.client quotes the offending header (a token, say).
|
|
780
|
+
reason = 'cabecera no válida'
|
|
781
|
+
else:
|
|
782
|
+
reason = type(error).__name__
|
|
783
|
+
raise ImageError('no se pudo descargar ({0})'.format(reason)) \
|
|
784
|
+
from None
|
|
769
785
|
if len(data) > max_bytes:
|
|
770
786
|
raise ImageError('imagen demasiado grande')
|
|
771
787
|
return data, path
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.7.1
|
|
4
4
|
Summary: Fast, dependency-free terminal tables for Python: 54 border styles, ANSI colors, cell merges, decimal alignment, width fitting, and CSV/Markdown/HTML/Excel/LaTeX I/O.
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -46,15 +46,15 @@ Requires-Dist: openpyxl>=3.0; extra == "excel"
|
|
|
46
46
|
Provides-Extra: html
|
|
47
47
|
Requires-Dist: lxml>=4.0; extra == "html"
|
|
48
48
|
Provides-Extra: tui
|
|
49
|
-
Requires-Dist: flexablelib-tui==3.
|
|
49
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "tui"
|
|
50
50
|
Provides-Extra: components
|
|
51
|
-
Requires-Dist: flexablelib-components==3.
|
|
51
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "components"
|
|
52
52
|
Provides-Extra: speed
|
|
53
|
-
Requires-Dist: flexablelib-speedups==3.
|
|
53
|
+
Requires-Dist: flexablelib-speedups==3.7.1; extra == "speed"
|
|
54
54
|
Provides-Extra: images
|
|
55
55
|
Requires-Dist: Pillow>=8; extra == "images"
|
|
56
|
-
Requires-Dist: flexablelib-tui==3.
|
|
57
|
-
Requires-Dist: flexablelib-components==3.
|
|
56
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "images"
|
|
57
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "images"
|
|
58
58
|
Provides-Extra: svg
|
|
59
59
|
Requires-Dist: cairosvg>=2.5; extra == "svg"
|
|
60
60
|
Provides-Extra: all
|
|
@@ -62,9 +62,9 @@ Requires-Dist: pandas>=1.0; extra == "all"
|
|
|
62
62
|
Requires-Dist: openpyxl>=3.0; extra == "all"
|
|
63
63
|
Requires-Dist: lxml>=4.0; extra == "all"
|
|
64
64
|
Requires-Dist: Pillow>=8; extra == "all"
|
|
65
|
-
Requires-Dist: flexablelib-tui==3.
|
|
66
|
-
Requires-Dist: flexablelib-components==3.
|
|
67
|
-
Requires-Dist: flexablelib-speedups==3.
|
|
65
|
+
Requires-Dist: flexablelib-tui==3.7.1; extra == "all"
|
|
66
|
+
Requires-Dist: flexablelib-components==3.7.1; extra == "all"
|
|
67
|
+
Requires-Dist: flexablelib-speedups==3.7.1; extra == "all"
|
|
68
68
|
Dynamic: author
|
|
69
69
|
Dynamic: author-email
|
|
70
70
|
Dynamic: classifier
|
|
@@ -189,6 +189,9 @@ in colour or plain text: the full list, what each does and its keys is in
|
|
|
189
189
|
<tr>
|
|
190
190
|
<td colspan="2"><b>New in 3.6.0</b> — signature pad, stopwatch, a vertical stack that shares its height and follows the focus, focus shown without colour, forms that collect nested fields and editable tables, scanners that keep the code read, catalog cards with pictures, pictures downloaded with an <code>Authorization</code> header, a validation summary from a list of errors<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v36/01_novedades.png" alt="3.6.0 components: SignatureInput, Stopwatch, VStack, focus markers, ScanInput, CatalogGrid with images, ValidationSummary" width="520"></td>
|
|
191
191
|
</tr>
|
|
192
|
+
<tr>
|
|
193
|
+
<td colspan="2"><b>New in 3.7.0</b> — scroll views that follow the focus, menus and sidebars that keep to their height, responsive form columns with spans, tables that fill their slot, an accessible grid with its own audit, a status line for screen readers<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v36/02_novedades_370.png" alt="3.7.0 components: ScrollView following the focus, Menu and Sidebar windows, Form grid, DataTable fill, GridView, StatusLine" width="520"></td>
|
|
194
|
+
</tr>
|
|
192
195
|
</table>
|
|
193
196
|
|
|
194
197
|
### Keyboard, mouse and accessibility
|
|
@@ -109,6 +109,8 @@ tests/test_v353_fixes.py
|
|
|
109
109
|
tests/test_v354_fixes.py
|
|
110
110
|
tests/test_v355_fixes.py
|
|
111
111
|
tests/test_v360_features.py
|
|
112
|
+
tests/test_v370_features.py
|
|
113
|
+
tests/test_v371_fixes.py
|
|
112
114
|
tests/wincon_child.py
|
|
113
115
|
tools/bench_frames.py
|
|
114
116
|
tools/bench_images.py
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
[all]
|
|
3
|
+
pandas>=1.0
|
|
4
|
+
openpyxl>=3.0
|
|
5
|
+
lxml>=4.0
|
|
6
|
+
Pillow>=8
|
|
7
|
+
flexablelib-tui==3.7.1
|
|
8
|
+
flexablelib-components==3.7.1
|
|
9
|
+
flexablelib-speedups==3.7.1
|
|
10
|
+
|
|
11
|
+
[components]
|
|
12
|
+
flexablelib-components==3.7.1
|
|
13
|
+
|
|
14
|
+
[excel]
|
|
15
|
+
openpyxl>=3.0
|
|
16
|
+
|
|
17
|
+
[html]
|
|
18
|
+
lxml>=4.0
|
|
19
|
+
|
|
20
|
+
[images]
|
|
21
|
+
Pillow>=8
|
|
22
|
+
flexablelib-tui==3.7.1
|
|
23
|
+
flexablelib-components==3.7.1
|
|
24
|
+
|
|
25
|
+
[pandas]
|
|
26
|
+
pandas>=1.0
|
|
27
|
+
|
|
28
|
+
[speed]
|
|
29
|
+
flexablelib-speedups==3.7.1
|
|
30
|
+
|
|
31
|
+
[svg]
|
|
32
|
+
cairosvg>=2.5
|
|
33
|
+
|
|
34
|
+
[tui]
|
|
35
|
+
flexablelib-tui==3.7.1
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"""3.7.0: a ScrollView that follows the focus, menus and sidebars that keep
|
|
2
|
+
to their height, responsive form columns with spans and minimum widths,
|
|
3
|
+
tables that fill their slot, a grid component with an accessible name and
|
|
4
|
+
its own audit, and a status line with the status role."""
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
C = pytest.importorskip('flexablelib_components')
|
|
9
|
+
|
|
10
|
+
from flexablelib import Card # noqa: E402
|
|
11
|
+
from flexablelib.layout import GridCell # noqa: E402
|
|
12
|
+
from flexablelib_tui import (App, Key, ScrollView, # noqa: E402
|
|
13
|
+
accessibility as a11y)
|
|
14
|
+
from flexablelib_tui.keys import MouseEvent # noqa: E402
|
|
15
|
+
from flexablelib.text_width import strip_ansi # noqa: E402
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def key(name):
|
|
19
|
+
if len(name) == 1:
|
|
20
|
+
return Key(name, name)
|
|
21
|
+
return Key(name)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pytest.fixture(autouse=True)
|
|
25
|
+
def plain_a11y():
|
|
26
|
+
with a11y.configure(screen_reader=False, ascii=False, reduced_motion=False,
|
|
27
|
+
focus_marker=False):
|
|
28
|
+
yield
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def lines(comp, width=30, height=None):
|
|
32
|
+
return [l.rstrip() for l in
|
|
33
|
+
strip_ansi(comp.render(width=width, height=height)).split('\n')]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# 9. ScrollView follows the focus
|
|
37
|
+
|
|
38
|
+
class TestScrollViewFocus:
|
|
39
|
+
def test_follows_tab(self):
|
|
40
|
+
fields = [C.TextInput('Campo {0}'.format(i)) for i in range(10)]
|
|
41
|
+
view = ScrollView(C.Stack(fields), height=6)
|
|
42
|
+
app = App(body=view)
|
|
43
|
+
app.run(keys=[], size=(40, 6))
|
|
44
|
+
while app.focused is not fields[7]:
|
|
45
|
+
app.dispatch(key('tab'))
|
|
46
|
+
frame = strip_ansi(app.render(40, 6))
|
|
47
|
+
assert 'Campo 7' in frame
|
|
48
|
+
assert view.offset > 0
|
|
49
|
+
assert view.focus_rows(39) is not None
|
|
50
|
+
view.scroll_to(0) # by hand: left alone
|
|
51
|
+
app.render(40, 6)
|
|
52
|
+
assert view.offset == 0
|
|
53
|
+
app.dispatch(key('tab')) # focus moves again: follows
|
|
54
|
+
app.render(40, 6)
|
|
55
|
+
assert 'Campo 8' in strip_ansi(app.render(40, 6))
|
|
56
|
+
while app.focused is not fields[1]:
|
|
57
|
+
app.dispatch(key('tab'))
|
|
58
|
+
app.render(40, 6)
|
|
59
|
+
assert view.offset <= 4
|
|
60
|
+
|
|
61
|
+
def test_off_and_edges(self):
|
|
62
|
+
fields = [C.TextInput('Campo {0}'.format(i)) for i in range(10)]
|
|
63
|
+
view = ScrollView(C.Stack(fields), height=6, follow_focus=False)
|
|
64
|
+
app = App(body=view)
|
|
65
|
+
app.run(keys=[], size=(40, 6))
|
|
66
|
+
for _ in range(8):
|
|
67
|
+
app.dispatch(key('tab'))
|
|
68
|
+
app.render(40, 6)
|
|
69
|
+
assert view.offset == 0
|
|
70
|
+
assert ScrollView('texto').focus_rows(10) is None
|
|
71
|
+
lone = ScrollView(C.TextInput('x'))
|
|
72
|
+
assert lone.focus_rows(10) is None # no app
|
|
73
|
+
big = C.TextArea('Notas', '\n'.join('l%d' % i for i in range(20)),
|
|
74
|
+
rows=15)
|
|
75
|
+
tall = ScrollView(C.Stack([C.TextInput('a'), big]), height=5)
|
|
76
|
+
app2 = App(body=tall)
|
|
77
|
+
app2.run(keys=[], size=(30, 5))
|
|
78
|
+
app2.focus(big)
|
|
79
|
+
app2.render(30, 5)
|
|
80
|
+
assert tall.offset == tall.focus_rows(29)[0]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# 10. Menu and Sidebar keep to the height
|
|
84
|
+
|
|
85
|
+
class TestMenuHeight:
|
|
86
|
+
def test_menu_window(self):
|
|
87
|
+
picked = []
|
|
88
|
+
m = C.Menu(['Opción {0}'.format(i) for i in range(20)],
|
|
89
|
+
on_select=lambda i, it: picked.append(i), use_colors=False)
|
|
90
|
+
out = lines(m, 20, 6)
|
|
91
|
+
assert len(out) == 6 and out[-1] == ' v 15 más'
|
|
92
|
+
m.focused = True
|
|
93
|
+
for _ in range(10):
|
|
94
|
+
m.handle_key(key('down'))
|
|
95
|
+
out = lines(m, 20, 6)
|
|
96
|
+
assert out[0].startswith(' ^') and out[-1].startswith(' v')
|
|
97
|
+
assert any('Opción 10' in l for l in out)
|
|
98
|
+
assert m.handle_key(key('pagedown')) and m.index == 14
|
|
99
|
+
assert m.handle_key(key('scrollup')) and m.index == 11
|
|
100
|
+
m.handle_key(key('end'))
|
|
101
|
+
out = lines(m, 20, 6)
|
|
102
|
+
assert 'Opción 19' in out[-1] and out[0].startswith(' ^')
|
|
103
|
+
m.render(width=20, height=6)
|
|
104
|
+
m.on_mouse(MouseEvent(0, 2, 0, True)) # click the ▲ line: page up
|
|
105
|
+
assert m.index < 19
|
|
106
|
+
m.render(width=20, height=6)
|
|
107
|
+
m.on_mouse(MouseEvent(0, 2, 2, True)) # an item: selects it
|
|
108
|
+
assert picked
|
|
109
|
+
for _ in range(30):
|
|
110
|
+
m.handle_key(key('pagedown'))
|
|
111
|
+
assert m.index == 19
|
|
112
|
+
for _ in range(30):
|
|
113
|
+
m.handle_key(key('pageup'))
|
|
114
|
+
assert m.index == 0
|
|
115
|
+
m.render(width=20, height=6)
|
|
116
|
+
m.on_mouse(MouseEvent(0, 2, 5, True)) # the ▼ line: page down
|
|
117
|
+
assert m.index > 0
|
|
118
|
+
assert len(lines(m, 20, 2)) == 2 # too short for arrows
|
|
119
|
+
assert C.Menu([]).handle_key(key('pagedown')) is False
|
|
120
|
+
|
|
121
|
+
def test_coloured_arrows_and_max_visible(self):
|
|
122
|
+
m = C.Menu(['x%d' % i for i in range(9)], max_visible=4,
|
|
123
|
+
use_colors=True)
|
|
124
|
+
assert '▼ 6 más' in strip_ansi(m.render(width=20))
|
|
125
|
+
|
|
126
|
+
def test_sidebar_window(self):
|
|
127
|
+
sections = {'Ventas': ['V%d' % i for i in range(10)],
|
|
128
|
+
'Compras': ['C%d' % i for i in range(10)]}
|
|
129
|
+
sb = C.Sidebar(sections, title='Menú', use_colors=False)
|
|
130
|
+
out = lines(sb, 20, 8)
|
|
131
|
+
assert len(out) == 8 and out[0] == ' Menú' and \
|
|
132
|
+
out[-1].startswith(' v')
|
|
133
|
+
sb.focused = True
|
|
134
|
+
for _ in range(15):
|
|
135
|
+
sb.handle_key(key('down'))
|
|
136
|
+
out = lines(sb, 20, 8)
|
|
137
|
+
assert out[0] == ' Menú' and out[2].startswith(' ^')
|
|
138
|
+
assert any('C' in l and '>' in l for l in out)
|
|
139
|
+
sb.render(width=20, height=8)
|
|
140
|
+
sb.on_mouse(MouseEvent(0, 3, 4, True))
|
|
141
|
+
assert sb.active == sb.index
|
|
142
|
+
app = App(body=C.AppShell(sidebar=sb, content='hola'))
|
|
143
|
+
app.run(keys=[], size=(40, 8))
|
|
144
|
+
assert len(app.last_frame.split('\n')) == 8
|
|
145
|
+
full = C.Sidebar({'A': ['a', 'b']}, use_colors=False)
|
|
146
|
+
out = lines(full, 20, 10)
|
|
147
|
+
assert out[:3] == [' A', '*a', ' b'] and not any(
|
|
148
|
+
l.startswith((' ^', ' v')) for l in out)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
# 11. Form: responsive columns, spans, minimum widths
|
|
152
|
+
|
|
153
|
+
class TestFormGrid:
|
|
154
|
+
def make(self, **kw):
|
|
155
|
+
a = C.TextInput('Nombre')
|
|
156
|
+
b = C.TextInput('Apellido')
|
|
157
|
+
c = C.TextInput('Dirección')
|
|
158
|
+
d = C.TextInput('CP')
|
|
159
|
+
form = C.Form([a, b, C.FormCell(c, span=2), 'Más',
|
|
160
|
+
C.FormCell(d, min_width=30)], columns=2,
|
|
161
|
+
use_colors=False, cancel_label=None, **kw)
|
|
162
|
+
return form, (a, b, c, d)
|
|
163
|
+
|
|
164
|
+
def test_spans_and_min_width(self):
|
|
165
|
+
form, (a, b, c, d) = self.make()
|
|
166
|
+
out = lines(form, 60)
|
|
167
|
+
assert 'Nombre' in out[0] and 'Apellido' in out[0]
|
|
168
|
+
addr = [l for l in out if 'Dirección' in l][0]
|
|
169
|
+
assert 'CP' not in addr
|
|
170
|
+
cp = [l for l in out if l.startswith('CP')]
|
|
171
|
+
assert cp # 29 < 30: takes the whole row
|
|
172
|
+
assert form.fields() == [a, b, c, d]
|
|
173
|
+
assert form.grid_columns(60) == 2
|
|
174
|
+
|
|
175
|
+
def test_responsive_columns(self):
|
|
176
|
+
form, _ = self.make(min_column_width=30)
|
|
177
|
+
assert form.grid_columns(70) == 2 and form.grid_columns(50) == 1
|
|
178
|
+
out = lines(form, 50)
|
|
179
|
+
nombre = [l for l in out if 'Nombre' in l][0]
|
|
180
|
+
assert 'Apellido' not in nombre
|
|
181
|
+
wide = lines(form, 80)
|
|
182
|
+
assert any('Nombre' in l and 'Apellido' in l for l in wide)
|
|
183
|
+
|
|
184
|
+
def test_tuple_rows_and_set_layout(self):
|
|
185
|
+
a, b, c = C.TextInput('A'), C.TextInput('B'), C.TextInput('C')
|
|
186
|
+
form = C.Form([(a, b), c], columns=3, use_colors=False)
|
|
187
|
+
form.set_layout(c, span=3)
|
|
188
|
+
out = lines(form, 60)
|
|
189
|
+
assert any(l.startswith('A') and 'B' in l for l in out)
|
|
190
|
+
assert form._draw_grid(60)
|
|
191
|
+
assert C.FormCell(a, span=0).span == 1
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# 12. DataTable fits the height
|
|
195
|
+
|
|
196
|
+
class TestTableHeight:
|
|
197
|
+
def test_fill_in_a_vstack(self):
|
|
198
|
+
t = C.DataTable(['n'], [[i] for i in range(50)], fill=True,
|
|
199
|
+
use_colors=False)
|
|
200
|
+
st = C.VStack([C.TextInput('Buscar'), t], height=12)
|
|
201
|
+
assert st.weights == [0, 1]
|
|
202
|
+
app = App(body=st)
|
|
203
|
+
app.run(keys=[], size=(30, 12))
|
|
204
|
+
app.focus(t)
|
|
205
|
+
for _ in range(20):
|
|
206
|
+
app.dispatch(key('down'))
|
|
207
|
+
frame = [l.rstrip() for l in strip_ansi(app.render(30, 12))
|
|
208
|
+
.split('\n')]
|
|
209
|
+
assert len(frame) == 12 and frame[-1] == '21/50'
|
|
210
|
+
assert t.visible_rows == 12 - 2 - 2 - 1
|
|
211
|
+
assert any(l.strip() == '> 20' or l.startswith('> 20') or
|
|
212
|
+
'20' in l for l in frame)
|
|
213
|
+
|
|
214
|
+
def test_fill_pads_short_tables(self):
|
|
215
|
+
t = C.DataTable(['n'], [[1], [2]], fill=True, use_colors=False)
|
|
216
|
+
out = lines(t, 20, 8)
|
|
217
|
+
assert len(out) == 8 and out[-1] == '1/2' and t.expand
|
|
218
|
+
assert C.DataTable(['n'], []).visible_rows == 10
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
# 13. GridView
|
|
222
|
+
|
|
223
|
+
class TestGridView:
|
|
224
|
+
def test_name_role_and_audit(self):
|
|
225
|
+
ok = C.Button('Guardar', lambda: None)
|
|
226
|
+
field = C.TextInput('Nombre')
|
|
227
|
+
g = C.GridView([Card('A', 'a'), (field, 1), GridCell(ok)],
|
|
228
|
+
title='Tablero', columns=3, use_colors=False)
|
|
229
|
+
info = g.a11y()
|
|
230
|
+
assert info['role'] == 'group' and info['label'] == 'Tablero'
|
|
231
|
+
assert info['value'] == '3 elementos'
|
|
232
|
+
assert g.children()[1:] == [field, ok]
|
|
233
|
+
out = lines(g, 60)
|
|
234
|
+
assert out[0] == 'Tablero' and 'Nombre' in ' '.join(out)
|
|
235
|
+
assert g.audit(width=30) == []
|
|
236
|
+
assert g.natural_width() > 0
|
|
237
|
+
assert len(lines(g, 60, 3)) == 3
|
|
238
|
+
app = App(body=g)
|
|
239
|
+
app.run(keys=['tab'], size=(60, 6))
|
|
240
|
+
assert app.focused in (field, ok)
|
|
241
|
+
|
|
242
|
+
def test_audit_reports(self):
|
|
243
|
+
class Plain(C.Box.__mro__[1]):
|
|
244
|
+
focusable = True
|
|
245
|
+
role = 'button'
|
|
246
|
+
|
|
247
|
+
def draw(self, width, height):
|
|
248
|
+
return [self.paint('x', 'cyan' if self.focused else 'blue')]
|
|
249
|
+
g = C.GridView([Plain(), C.Stack([C.Image(b'', alt=None)])],
|
|
250
|
+
role='grid')
|
|
251
|
+
checks = sorted(i.check for i in g.audit())
|
|
252
|
+
assert checks.count('label') >= 3 # grid, button, image
|
|
253
|
+
assert 'focus' in checks and g.a11y()['role'] == 'grid'
|
|
254
|
+
named = C.GridView(['x'], a11y_label='Resumen')
|
|
255
|
+
assert named.a11y_name() == 'Resumen' and named.children() == []
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
# 14. StatusLine
|
|
259
|
+
|
|
260
|
+
class TestStatusLine:
|
|
261
|
+
def test_render_and_role(self):
|
|
262
|
+
clock = ['12:00']
|
|
263
|
+
sl = C.StatusLine('Listo', center='3 elementos',
|
|
264
|
+
right=lambda: clock[0], kind='success',
|
|
265
|
+
use_colors=False)
|
|
266
|
+
out = strip_ansi(sl.render(width=40))
|
|
267
|
+
assert out.startswith(' ✔ Listo') and out.endswith('12:00 ')
|
|
268
|
+
assert '3 elementos' in out
|
|
269
|
+
info = sl.a11y()
|
|
270
|
+
assert info['role'] == 'status' and info['label'] == 'Estado'
|
|
271
|
+
assert info['value'] == 'Éxito: Listo · 3 elementos · 12:00'
|
|
272
|
+
clock[0] = '12:01'
|
|
273
|
+
assert '12:01' in sl.render(width=40)
|
|
274
|
+
coloured = C.StatusLine('x', use_colors=True)
|
|
275
|
+
assert '\x1b[' in coloured.render(width=20)
|
|
276
|
+
assert coloured.natural_width() >= 3
|
|
277
|
+
assert C.StatusLine(a11y_label='Barra').a11y_name() == 'Barra'
|
|
278
|
+
assert C.StatusLine(kind='error').a11y_value() == 'Error'
|
|
279
|
+
assert C.StatusLine(left=None).parts() == ('', '', '')
|
|
280
|
+
|
|
281
|
+
def test_announces_changes(self):
|
|
282
|
+
said = []
|
|
283
|
+
sl = C.StatusLine('Listo')
|
|
284
|
+
app = App(body=sl)
|
|
285
|
+
app.announce = lambda text, priority='polite': said.append(
|
|
286
|
+
(text, priority))
|
|
287
|
+
app.run(keys=[], size=(30, 2))
|
|
288
|
+
sl.message('Guardado', 'success')
|
|
289
|
+
sl.set(kind='error', left='Sin conexión')
|
|
290
|
+
sl.set(center='') # nothing new: silent
|
|
291
|
+
assert said == [('Éxito: Guardado', 'polite'),
|
|
292
|
+
('Error: Sin conexión', 'assertive')]
|
|
293
|
+
quiet = C.StatusLine('x', announce=False)
|
|
294
|
+
quiet.app = app
|
|
295
|
+
quiet.set(left='y', right='z', kind=None)
|
|
296
|
+
assert len(said) == 2 and quiet.parts() == ('y', '', 'z')
|