visualdynamics.gui.tables¶
tables
¶
Tables that behave like a spreadsheet.
Model/view rather than per-cell widgets, so a table costs nothing until it is scrolled, edits write straight back to the underlying visualdynamics object with validation, and switching display units restates the values without rebuilding anything.
CopyPasteTableView speaks Excel's clipboard format — tab-separated text,
newline-separated rows — so a selection copies straight into a spreadsheet
and a block of spreadsheet cells pastes back in.
Classes:
| Name | Description |
|---|---|
Column |
One column: how to read it, how to show it, whether it can be set. |
TableModel |
A table over a visualdynamics object, described by a list of Columns. |
ChoiceDialog |
Pick one of a column's choices, shown the way its cells show them. |
ChoiceDelegate |
Edit a column that declares |
CopyPasteTableView |
A table view with spreadsheet clipboard behaviour. |
Functions:
| Name | Description |
|---|---|
trace_units |
A witness line per units-editor event, like the drop log: the |
Classes¶
Column
dataclass
¶
Column(
title: str,
get: Callable,
set: Callable | None = None,
format: Callable | None = None,
decoration: Callable | None = None,
background: Callable | None = None,
choices: list | None = None,
choice_icon: Callable | None = None,
row_choices: Callable | None = None,
choices_editable: bool = False,
checkbox: bool = False,
date: bool = False,
affects_row: bool = False,
carries: tuple = (),
journal: Callable | None = None,
alignment: int = int(AlignRight | AlignVCenter),
)
One column: how to read it, how to show it, whether it can be set.
Methods:
| Name | Description |
|---|---|
choices_for |
What one cell offers, which can be narrower than the column's list. |
Methods:¶
choices_for
¶
What one cell offers, which can be narrower than the column's list.
A channel the file said was an acceleration should offer four units, not all twenty-one, while the channel below it offers its own four.
Source code in src/visualdynamics/gui/tables.py
TableModel
¶
TableModel(
obj: Any,
columns: Sequence[Column],
row_count: Callable[[Any], int],
parent: QObject | None = None,
)
Bases: QAbstractTableModel
A table over a visualdynamics object, described by a list of Columns.
Methods:
| Name | Description |
|---|---|
refresh_row |
Restate one row, leaving the selection alone. |
set_cells |
Write a different value into each of many cells, as one change. |
set_many |
Write one value into many cells, reporting a single change — |
Source code in src/visualdynamics/gui/tables.py
Methods:¶
refresh_row
¶
Restate one row, leaving the selection alone.
A full reset clears the selection, which matters when the selection is what the edit applies to — turning a coordinate system would lose the very system being turned.
Source code in src/visualdynamics/gui/tables.py
set_cells
¶
Write a different value into each of many cells, as one change.
set_many puts one value everywhere and is written over this;
here each cell gets its own. One dataChanged for the lot: cell-by-
cell setData would emit once per cell, and every one of those
redraws the 3D view, so setting a column of a few thousand nodes
has to cost one redraw, not a few thousand.
Cells that refuse the value are left alone and counted, so a batch that only partly lands is not mistaken for a clean one; the first refusal's reason comes back with the counts.
Source code in src/visualdynamics/gui/tables.py
set_many
¶
Write one value into many cells, reporting a single change —
set_cells with the same text for every cell.
Source code in src/visualdynamics/gui/tables.py
ChoiceDialog
¶
ChoiceDialog(
parent: QWidget | None, prompt: str, column: Column
)
Bases: QDialog
Pick one of a column's choices, shown the way its cells show them.
Batch editing a column of colours should offer the same list of colours as editing one cell of it, not a box to type a colour name into.
Source code in src/visualdynamics/gui/tables.py
ChoiceDelegate
¶
Bases: QStyledItemDelegate
Edit a column that declares choices with a drop-down.
Opening the cell opens the list: a closed combo box would make the user click twice to see what the choices even are. Picking one applies it and closes, rather than waiting for focus to move away.
Typing still works — the model accepts the same values either way — so pasting a column of them from a spreadsheet is unaffected.
Methods:
| Name | Description |
|---|---|
paint |
Mark the selected cell of a choice column with a drop-down arrow. |
Methods:¶
paint
¶
Mark the selected cell of a choice column with a drop-down arrow.
Otherwise there is nothing to say a cell has a list behind it until you have already opened one. Only the selected cell is marked: an arrow in every cell of a 200k-row column is noise, and a spreadsheet marks the active cell the same way.
The arrow is the platform's own — asking the style for a combo box's arrow sub-control, so it is whatever a real drop-down would draw here — rather than something hand-drawn that would look foreign.
Source code in src/visualdynamics/gui/tables.py
CopyPasteTableView
¶
Bases: QTableView
A table view with spreadsheet clipboard behaviour.
Methods:
| Name | Description |
|---|---|
selected_block |
(rows, columns) covered by the selection, as sorted lists. |
paste |
Paste tab-separated text over the selection's top-left corner. |
editable_selection |
The selected cells that will accept a value. |
shared_choices |
The Column the selection shares, when they all offer one list. |
batch_edit |
Set every selected cell to one value, across columns as well. |
whole_rows |
Rows whose every column is selected — a row-header click, or a |
clear_cells |
Empty the selected cells, for the columns that accept empty. |
fill_handle_rect |
The little square at the bottom-right of the selection, or None. |
fill_from_selection |
Repeat the selected block over the rows out to |
mouseDoubleClickEvent |
Double-clicking the handle fills all the way down, as Excel does. |
Source code in src/visualdynamics/gui/tables.py
Methods:¶
selected_block
¶
(rows, columns) covered by the selection, as sorted lists.
Source code in src/visualdynamics/gui/tables.py
paste
¶
Paste tab-separated text over the selection's top-left corner.
Cells that will not accept a value are left alone and counted, so a paste that partly lands is not silently half-applied.
Source code in src/visualdynamics/gui/tables.py
editable_selection
¶
The selected cells that will accept a value.
Source code in src/visualdynamics/gui/tables.py
shared_choices
¶
shared_choices(
indexes: Sequence[QModelIndex],
) -> Column | None
The Column the selection shares, when they all offer one list.
A selection spanning a colour column and a coordinate column has no common list, so it falls back to typing a value.
Source code in src/visualdynamics/gui/tables.py
batch_edit
¶
Set every selected cell to one value, across columns as well.
Pass text to skip the prompt.
Source code in src/visualdynamics/gui/tables.py
whole_rows
¶
Rows whose every column is selected — a row-header click, or a drag across the full width. The distinction Delete turns on.
Source code in src/visualdynamics/gui/tables.py
clear_cells
¶
Empty the selected cells, for the columns that accept empty.
A column that cannot be blank — a node id, a connectivity list — refuses and is counted, exactly as it would refuse the same value typed in. Nothing here decides what empty means; the column does.
Source code in src/visualdynamics/gui/tables.py
fill_handle_rect
¶
The little square at the bottom-right of the selection, or None.
Excel's affordance, and the fastest way to carry one value down a column without selecting the whole thing first.
Source code in src/visualdynamics/gui/tables.py
fill_from_selection
¶
Repeat the selected block over the rows out to through.
The block repeats rather than only its last row, so filling from two alternating rows carries the alternation — which is what a spreadsheet does and what makes it worth dragging two cells.
Source code in src/visualdynamics/gui/tables.py
mouseDoubleClickEvent
¶
Double-clicking the handle fills all the way down, as Excel does.
The common case is "this unit, for every channel"; dragging 45 rows to say it is a chore.
Source code in src/visualdynamics/gui/tables.py
Functions:¶
trace_units
¶
A witness line per units-editor event, like the drop log: the instantly-closing drop-down could not be reproduced by synthetic clicks, so the real click writes its own story (~/Library/Logs/VisualDynamics-units.log, truncated per session by the first line written).