Interactive Table

Hey everyone :slight_smile: I just found Best way to implement interactive widgets · Issue #24 · Textualize/textual · GitHub and was wondering if it’s status has changed since July of last year… If so, what would be the best approach for an interactive Table widget. Are contributions for such a thing welcome/encouraged or should I hold out for 0.2 (css) to be released first?

EDIT: I would like to clarify “interactive table” a bit more: I’m thinking in terms of an interface where the Table is the main interface. A user should be able to navigate a highlighted row with keys and perform actions on the current (or a set of selected) rows using other key maps. So I’d like to figure out if textual should support a native “interactive Table” for such purposes or whether this should all be based on a simple, static rich table which gets continuously updated.

We’re planning to implement a data table widget which sounds similar to this. It is probably wise to wait for the CSS branch to land before attempting. Although if you’re brave and you want to get a head start you could use the CSS branch now, there is probably enough API to get started.

1 Like

Awesome to hear! If I were indeed to start on something like this I would consider writing it in a way to be mergable into Textual rather than tailored to my needs. Do you have any resources/guidelines which I should look into before doing so?
Do you also have some more specifics in mind for how this should shape up?

We’re planning to implement a data table widget

Will this be extensible? For example, I want to do a table widget with a pop-out date picker. Right now there is neither a date picker widget nor a data table widget, so I’m trying to decide where to start.

I figure the data picker is most useful since I can use it in other contexts before a data table is available. Are there any particular design rules I should keep in mind to make it easier to integrate with the eventual data table widget?

Better yet, has anyone already made a date picker and just neglected to upstream it? :innocent:

I was thinking about this some more and I think that it should be possible to put together a prototype of at least the technical aspects largely independent of the css branch. At least some design aspects as to whether you want to implement a TableWidget (whatever the final name will be) using inheritance or composition w.r.t. the Table class from rich.
Do you have an opinion/suggestion on this, @will?

Other design aspects which to me pose open questions:

  • I am assuming this will be a widget. How will this relate to the ScrollView widget?
  • Depending on the implementation it might make sense to either have another scrollable direction along the horizontal plane or to ensure the table fits the terminal width. How would you envision this?
  • I suggested that one can navigate this table using e.g. arrow keys. This would require the notion of a cursor. For this particular purpose it would make sense (imo) to implement a “cursor” as a notion of a currently active cell/row/column. What do you think of this?

I am not even sure if all of these questions would be handled by textual itself or by a package author who is using textual. Just let me know if I am totally off-topic here :smiley: