vimsheet.ui.grid
GridWidget — virtual-scrolling spreadsheet grid with variable row heights.
- class vimsheet.ui.grid.GridWidget(workbook, config=None, **kwargs)[source]
Bases:
ScrollViewVirtual-scrolling spreadsheet grid.
Each data row occupies a variable number of virtual lines based on the maximum newline count across all cells in that row. A live preview override allows insert/edit mode to show uncommitted multi-line content.
The column-header row is frozen at viewport y=0 regardless of scroll position. Data rows start at viewport y=1.
- Parameters:
workbook (Workbook)
config (Any)
kwargs (Any)
- BINDINGS = []
Keyboard bindings for scrollable containers.
Key(s) | Description |:- | :- |up | Scroll up, if vertical scrolling is available. |down | Scroll down, if vertical scrolling is available. |left | Scroll left, if horizontal scrolling is available. |right | Scroll right, if horizontal scrolling is available. |home | Scroll to the home position, if scrolling is available. |end | Scroll to the end position, if scrolling is available. |pageup | Scroll up one page, if vertical scrolling is available. |pagedown | Scroll down one page, if vertical scrolling is available. |ctrl+pageup | Scroll left one page, if horizontal scrolling is available. |ctrl+pagedown | Scroll right one page, if horizontal scrolling is available. |
- DEFAULT_CSS = '\n GridWidget {\n background: $surface;\n border: none;\n height: 1fr;\n scrollbar-size-horizontal: 0;\n scrollbar-size-vertical: 1;\n }\n '
Default TCSS.
- class CursorMoved(row, col)[source]
Bases:
MessageEmitted whenever the cursor row/col changes.
- time
- cursor_row: reactive[int]
Create a reactive attribute.
- Parameters:
default – A default value or callable that returns a default.
layout – Perform a layout on change.
repaint – Perform a repaint on change.
init – Call watchers on initialize (post mount).
always_update – Call watchers even when the new value equals the old value.
recompose – Compose the widget again when the attribute changes.
bindings – Refresh bindings when the reactive changes.
toggle_class – An optional TCSS classname(s) to toggle based on the truthiness of the value.
- cursor_col: reactive[int]
Create a reactive attribute.
- Parameters:
default – A default value or callable that returns a default.
layout – Perform a layout on change.
repaint – Perform a repaint on change.
init – Call watchers on initialize (post mount).
always_update – Call watchers even when the new value equals the old value.
recompose – Compose the widget again when the attribute changes.
bindings – Refresh bindings when the reactive changes.
toggle_class – An optional TCSS classname(s) to toggle based on the truthiness of the value.
- mode: reactive[Mode]
Create a reactive attribute.
- Parameters:
default – A default value or callable that returns a default.
layout – Perform a layout on change.
repaint – Perform a repaint on change.
init – Call watchers on initialize (post mount).
always_update – Call watchers even when the new value equals the old value.
recompose – Compose the widget again when the attribute changes.
bindings – Refresh bindings when the reactive changes.
toggle_class – An optional TCSS classname(s) to toggle based on the truthiness of the value.
- visual_anchor_row: reactive[int]
Create a reactive attribute.
- Parameters:
default – A default value or callable that returns a default.
layout – Perform a layout on change.
repaint – Perform a repaint on change.
init – Call watchers on initialize (post mount).
always_update – Call watchers even when the new value equals the old value.
recompose – Compose the widget again when the attribute changes.
bindings – Refresh bindings when the reactive changes.
toggle_class – An optional TCSS classname(s) to toggle based on the truthiness of the value.
- visual_anchor_col: reactive[int]
Create a reactive attribute.
- Parameters:
default – A default value or callable that returns a default.
layout – Perform a layout on change.
repaint – Perform a repaint on change.
init – Call watchers on initialize (post mount).
always_update – Call watchers even when the new value equals the old value.
recompose – Compose the widget again when the attribute changes.
bindings – Refresh bindings when the reactive changes.
toggle_class – An optional TCSS classname(s) to toggle based on the truthiness of the value.
- show_visual: reactive[bool]
Create a reactive attribute.
- Parameters:
default – A default value or callable that returns a default.
layout – Perform a layout on change.
repaint – Perform a repaint on change.
init – Call watchers on initialize (post mount).
always_update – Call watchers even when the new value equals the old value.
recompose – Compose the widget again when the attribute changes.
bindings – Refresh bindings when the reactive changes.
toggle_class – An optional TCSS classname(s) to toggle based on the truthiness of the value.
- __init__(workbook, config=None, **kwargs)[source]
Construct a scrollable container.
- Parameters:
*children – Child widgets.
name – The name of the widget.
id – The ID of the widget in the DOM.
classes – The CSS classes for the widget.
disabled – Whether the widget is disabled or not.
can_focus – Can this container be focused?
can_focus_children – Can this container’s children be focused?
can_maximized – Allow this container to maximize?
Noneto use default logic.,workbook (Workbook)
config (Any)
kwargs (Any)
- Return type:
None
- get_content_width(container, viewport)[source]
Gets the width of the content area.
- Parameters:
container (Size) – Size of the container (immediate parent) widget.
viewport (Size) – Size of the viewport.
- Returns:
The optimal width of the content.
- Return type:
- get_content_height(container, viewport, width)[source]
Gets the height (number of lines) in the content area.
- render_line(y)[source]
Render viewport line y (0 = frozen column-header row).
- Parameters:
y (int)
- Return type:
Strip
- can_focus = True
Widget may receive focus.
- can_focus_children = True
Widget’s children may receive focus.