Edit a cell in TableView

Say I have a table that I want to show from the REPL:

using Blink, TableView
n = 10
t = (id = 1:n, good = rand(Bool, n))
w = Blink.Window()
body!(w, showtable(t))

How exactly can I flip the true/false content in the cells (i.e. edit the contents of the cells), and then retrieve the new values?

You can’t. :slight_smile:
It should be possible to do this for some tables, but the Tables.jl doesn’t support mutating tables yet, afaict.

Which ones? I can use those instead.

A matrix or dataframe, for example. But as I said, Tables.jl doesn’t support mutating sources yet, so TableView.jl can’t either.
@quinnj (or maybe @piever) probably knows how realistic it is to get that anytime soon.

Ah… I thought you were referring to the fact that a named tuple such as the typeof t is considered a Table.table.

I see. Well, to be honest, I’m trying to avoid Gtk and use TableView as part of a UI. So perhaps not totally cosher to start with…

Thanks though!

It would be fairly trivial to do this for some tables, probably, but I’d really like to avoid special casing e.g. DataFrames (and depending on it, of course).

One thing we could also do is add a callback kwarg to showtable, which has the edited cell and the new value as its arguments. That would put the burden of figuring out how to mutate the table on you though :slight_smile:

Yea, keep it lean.

Sounds like a reasonable solution… At the end of the day isn’t it a text dialog?

1 Like

Yeah, there’s an open issue about this for Tables.jl. Part of the issue is that there is indeed a ton of variability in terms of which tables could support this; pretty much only in-memory sources, which would exclude file formats (feather, csv), most databases (sqlite, mysql, odbc), so it just hasn’t felt like a high priority given this would be exclusively for in-memory structures.

There was talk at one point of possibly enhancing or creating a new InMemoryTable interface that could add additional features like: mutability, requiring getindex and iteration on rows, etc.

2 Likes