This level of nested braces may appear to be something from a programming quiz but, actually, this is meaningful when adding new, empty rows to a gnocl::list widget.
Suppose an instance of a list widget is created with 2 columns containing plain text.
set lv(s) [gnocl::list \
-types [list string string] \
-titles {Keys Mapping}]
Appending new rows to the table is achieved using the widget subcommand add.
$lv(s) add ...
So, adding an empty row can be achieved using
$lv(s) add {{{} {}}}
The widget code expects a list of rows, with each member of this list itself being a list whose items correspond to the column entries. Sounds kind of confusing and complicated. Well, it is. Especially when empty rows are being added.
Lets work our way our way through it, from the inside out.
The list has two columns, and lets take the following as our staring point. We will write these items to the cells to be appended.
col-1 col-2
A list of two items. This needs to be converted to a list for the row, simply done with braces.
{col-1 col-2}
And, as only one row it to be added, this list forms a single entry if the list of rows.
{{col-1 col-2}}
If the data entries contains white space, then these would need to be surrounded by braces or quotes. So,
{{{col 1} {col 2}}}
Is the same as:
{{"col 1" "col 2"}}
Just to prove the point, lets add two rows.
{ {{r1c1} {r1c2}} {{r2c1} {r2c2}}}
All this single line bracing, especially with empty fields, has just been something to capture the imagination. The previous line could also have been written much more clearly as:
{
{ {r1c1} {r1c2} }
{ {r2c1} {r2c2} }
}
So, we can now see, that
{{{} {}}}
Is nothing other than:
{
{{} {}}
}
The addition of empty cells into 1 row, with 2 columns.
Comments