# Update \`table\` option for plugins

**URL:** <https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606>\
**Category:** Plugins\
**Created:** [November 27, 2026, 6:10am UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606 "2026-11-27T06:10:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![brockdyer03](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/brockdyer03/32/2015_2.png) [@brockdyer03](https://discuss.avogadro.cc/u/brockdyer03)\
**Post date:** [November 27, 2026, 6:10am UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/1 "2026-11-27T06:10:29Z")

</div>

## Current

The current `table` option for plugins is completely undocumented, and from my experience trying to implement one, very unintuitive. Here is a quick breakdown of how they work currently:

```toml
[TABLE]
label = "Test" # Same as every other item
type = "table"
toolTip = "This is a table" # Same as every other item
tab = "Basic" # Same as every other item
# Toggle ability to select entire rows. No support to select columns.
selectable = false
# The number of columns will grow to support however many headers are here
headers = ["header1", "header2", "header3"]
# Pass in defaults column-wise, also resizes table to fit all values
columns = [
    ["row0_col0", "row1_col0"],
    ["row0_col1", "row1_col1"],
    ["row0_col2", "row1_col2"],
]
# Alternatively, pass in defaults row-wise.
# If this is provided with columns, any overlap will be overwritten by rows
# This also will resize the table if necessary
rows = [
    ["row0_col0", "row0_col1", "row0_col2"],
    ["row1_col0", "row1_col1", "row1_col2"],
]
# This overrides both rows and columns, and will resize the table if necessary
default = "row0_col0\trow0_col1\trow0_col2\nrow1_col0\trow1_col1\trow1_col2"
# Delimiter will change the format of "default"
delimiter = "\t"
# Sortable does something, but I could not figure out its function
sortable = False

```

The plugin then receives (in this case) a string that represents tab-separated values in the same form as `default`:

```json
{
    "TABLE": "row0_col0\trow0_col1\trow0_col2\nrow1_col0\trow1_col1\trow1_col2"
}

```

## Proposed Changes

Some discussion with @matterhorn103 led to this proposed revision.

A more intuitive way to create a table would be to pass in an array of rows/columns, which could each contain information about what that entry in the table would look like, things like the header/label, the datatype, the defaults, and whether or not that row/column is editable. Additionally, passing both `rows` and `columns` would not be allowed, and passing `default` would be outright removed. Additionally, within a row/column, the datatype would be homogeneous.

This is what that would look like in TOML:

```toml
[TABLE]
label = "Test"
type = "table"
toolTip = "This is a table"
tab = "Basic"

[[TABLE.columns]]
label = "col1"
type = "integer"
minimum = 0
maximum = 9
defaults = [2, 5]

[[TABLE.columns]]
label = "col2"
type = "string"
defaults = ["row0_col1", "row1_col1"]

[[TABLE.columns]]
label = "col3"
type = "boolean"
editable = false
defaults = [true, false]

```

This allows for a number of important things. One, you can now control the widget inside the box (`QTableWidgetItem` for strings, `QSpinBox` and `QDoubleSpinBox` for integers and floats, respectively, and `QCheckBox` for bools), just like you would in other widgets. Being able to set a row/column as editable also would serve to enable a sort of row/column label if you have already labeled the other. This is useful for situations where the plugin sets a value based on the molecule passed, and the others need to be filled in by a user.

The table produced from this TOML is shown here:

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/4/45449922982abf7b22a0370b99219d8da90fda09.png)

In addition to updating the table specification, the return value from the table would also be updated to match the input more closely. This means that instead of return a string, Avogadro would return a JSON array with the rows/columns inside it, like this:

```json
{
  "TABLE": [
    {"col1": [2, 5]},
    {"col2": ["row1_col2", "row2_col2"]},
    {"col3": [false, false]}
  ]
}

```

This would make it much more intuitive to work with since the column labels you put in are exactly what you get back out, and the types match what you expect.

While this would break existing plugins using tables, I don’t actually think there are many plugins that use tables, since their API was quite complicated and completely undocumented, as mentioned at the beginning of this post.

I’ve already done the implementation of this [in a branch](https://github.com/brockdyer03/avogadrolibs/tree/new-tables), just to see if it is possible. If there is positive feedback, I’ll open a PR.

---

<div class="post-metadata">

**Author:** ![matterhorn103](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/matterhorn103/32/1751_2.png) [@matterhorn103](https://discuss.avogadro.cc/u/matterhorn103)\
**Post date:** [November 27, 2026, 1:47pm UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/2 "2026-11-27T13:47:49Z")

</div>

In my opinion the most valuable thing is for the input and output formats to match. So in this version of the proposal where `columns` is an array (of dictionaries), I’d say the output should match it and be an array (of arrays).

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [November 27, 2026, 1:48pm UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/3 "2026-11-27T13:48:02Z")

</div>

Apologies that I didn’t write docs on tables (which were added in 2.1) - I hacked the feature for the use case of “log into a WebMO instance and get a list of finished jobs for the user to select and download.”

The use case was more “display a bunch of tabular data” than what you’re describing, which seems to be “provide an editable table.”

> [@brockdyer03](#):
>
> While this would break existing plugins using tables,

No, I’m not currently aware of anything using tables, since I haven’t released the `avogadro-webmo` plugin yet. I think what you’re doing would be fine - although it means anything table-related has to wait until 2.2 because that would be the first release supporting your implementation.

---

<div class="post-metadata">

**Author:** ![matterhorn103](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/matterhorn103/32/1751_2.png) [@matterhorn103](https://discuss.avogadro.cc/u/matterhorn103)\
**Post date:** [November 27, 2026, 2:12pm UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/4 "2026-11-27T14:12:42Z")

</div>

We did have an earlier sketch where columns were specified in a dict keyed on an identifier (which was therefore unique) and then also passed to the plugin as a dict of arrays. This was really nice in our view, but then we remembered that dicts/hashmaps don’t maintain order outside of Python.

Having thought about it a little more, we could still do it, the order of columns would just have to be provided. One way of doing it would be like this:

```toml
[TABLE]
label = "Test"
type = "table"
toolTip = "This is a table"
tab = "Basic"
column-order = ["col1", "col2", "col3"] # Optional, otherwise order is arbitrary

[TABLE.columns.col1]
label = "Column 1"
type = "integer"
minimum = 0
maximum = 9
defaults = [2, 5]

[TABLE.columns.col2]
label = "Column 2"
type = "string"
defaults = ["row0_col1", "row1_col1"]

[TABLE.columns.col3]
type = "boolean"
editable = false
defaults = [true, false]

```

and then the plugin would receive the values like:

```json

{
  "TABLE": {
    "col1": [2, 5],
    "col2": ["row1_col2", "row2_col2"],
    "col3": [false, false],
 }
}

```

There are alternative ways to do this e.g. have the column as key/value pairs within `TABLE` rather than `TABLE.columns`, or to have each column specify its own position/index within its dict, but this is just one example.

My argument in favour of this would be that I do think it makes life easier for plugin authors when they can get stuff by key rather than index as much as possible. Indices are faffy and very prone to errors/bugs.

---

<div class="post-metadata">

**Author:** ![brockdyer03](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/brockdyer03/32/2015_2.png) [@brockdyer03](https://discuss.avogadro.cc/u/brockdyer03)\
**Post date:** [November 27, 2026, 6:50pm UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/5 "2026-11-27T18:50:06Z")

</div>

I do like the idea of providing order explicitly, but I don’t like the idea of repeating column labels several times. I’d suggest instead that we pass the column order inside each column:

```toml
[TABLE]
label = "Test"
type = "table"
toolTip = "This is a table"
tab = "Basic"

[TABLE.columns.col1]
label = "Column 1"
order = 0
type = "integer"
minimum = 0
maximum = 9
defaults = [2, 5]

[TABLE.columns.col2]
label = "Column 2"
order = 1
type = "string"
defaults = ["row0_col1", "row1_col1"]

[TABLE.columns.col3]
order = 2
type = "boolean"
editable = false
defaults = [true, false]

```

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [November 27, 2026, 9:26pm UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/6 "2026-11-27T21:26:19Z")

</div>

> [@brockdyer03](#):
>
> column order inside each column

Wouldn’t it make more sense to just have a list of column keys e.g. `columns` or `column_keys`?

```toml
[table]
label = "WebMO Jobs"
type = "table"
columns = ["col1", "col2", "col3"]

[table.columns.col1]
label = "Column 1"
type = "integer"
…

```

---

<div class="post-metadata">

**Author:** ![brockdyer03](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/brockdyer03/32/2015_2.png) [@brockdyer03](https://discuss.avogadro.cc/u/brockdyer03)\
**Post date:** [November 27, 2026, 9:29pm UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/7 "2026-11-27T21:29:35Z")

</div>

> [@ghutchis](#):
>
> Wouldn’t it make more sense to just have a list of column keys e.g. `columns` or `column_keys`?

If this was the case, plugin authors would always have to duplicate the column names, therefore an update would need updates in two places. By having the order inside the column, code duplication is minimized.

I’ve gotten my version working, but if the opinion is strongly in favor of a separate listing to determine order, I can implement that too.

Here is what I have:  
TOML:

```toml
[TABLE]
label = "Test"
type = "table"
toolTip = "This is a table"
tab = "Basic"

[TABLE.columns.col1]
label = "Column 1"
order = 0
type = "integer"
minimum = 0
maximum = 9
defaults = [2, 5]

[TABLE.columns.col2]
label = "Column 2"
order = 1
type = "string"
defaults = ["row0_col1", "row1_col1"]

[TABLE.columns.col3]
order = 2
type = "boolean"
editable = false
defaults = [true, false]

```

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/c/cc6bf3f39ba8078e6d1f16e8e0c2950a77f25ae2.png)

Return value:

```json
{
  "TABLE": {
    "Column 1": [2, 5],
    "Column 2": ["row0_col1", "row1_col1"],
    "col3": [true, false]
  }
}

```

---

<div class="post-metadata">

**Author:** ![matterhorn103](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/matterhorn103/32/1751_2.png) [@matterhorn103](https://discuss.avogadro.cc/u/matterhorn103)\
**Post date:** [November 27, 2026, 10:46pm UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/8 "2026-11-27T22:46:35Z")

</div>

That doesn’t work, because `table.columns` is defined twice – the equivalent JSON would be:

```json
{
  "table": {
    "label": "WebMO Jobs",
    "type": "table",
    "columns": [
      "col1",
      "col2",
      "col3"
    ],
    "columns": {
      "col1": {
        "label": "Column 1",
        "type": "integer",
      }
    }
  }
}

```

However, if the list of columns was called `column_keys` or `column-keys` or `column-order` (as in my example) then it would work fine like that, yeah.

---

<div class="post-metadata">

**Author:** ![matterhorn103](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/matterhorn103/32/1751_2.png) [@matterhorn103](https://discuss.avogadro.cc/u/matterhorn103)\
**Post date:** [November 27, 2026, 10:47pm UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/9 "2026-11-27T22:47:37Z")

</div>

> [@brockdyer03](#):
>
> Return value:
> 
> ```json
> {
> "TABLE": {
> "Column 1": [2, 5],
> "Column 2": ["row0_col1", "row1_col1"],
> "col3": [true, false]
> }
> }
> 
> ```

The keys of this should be the same keys used in `TABLE.columns` in the definition though, not the `label` values.

But otherwise, looks great to me!

---

<div class="post-metadata">

**Author:** ![brockdyer03](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/brockdyer03/32/2015_2.png) [@brockdyer03](https://discuss.avogadro.cc/u/brockdyer03)\
**Post date:** [November 27, 2026, 10:54pm UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/10 "2026-11-27T22:54:57Z")

</div>

> [@matterhorn103](#):
>
> The keys of this should be the same keys used in `TABLE.columns` in the definition though, not the `label` values.

This wouldn’t work because the table does not store the original column key. We could just make it so that the original column key is the header, which would make a lot more sense in my opinion.

---

<div class="post-metadata">

**Author:** ![brockdyer03](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/brockdyer03/32/2015_2.png) [@brockdyer03](https://discuss.avogadro.cc/u/brockdyer03)\
**Post date:** [November 28, 2026, 6:58am UTC](https://discuss.avogadro.cc/t/update-table-option-for-plugins/7606/11 "2026-11-28T06:58:01Z")

</div>

If anyone is curious, I opened [a PR](https://github.com/OpenChemistry/avogadrolibs/pull/3470) for this feature.

By the way, I added support for filePath and stringList widgets in addition to the others, so now anything that could go into a regular widget can go into a table.
