-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table Container #724
base: master
Are you sure you want to change the base?
Table Container #724
Conversation
This is a the initial implementation of the Table container. This implementation extends HSplit and VSplit for the bulk of the logic.
We can now properly merge cells where the merged cells are rendered correctly according to a summation of the merged widths. Our table supports the column_width and column_widths parameters, the first being the default column dimension preference, the second being the column dimension preference given a specific index.
Here's an example of what this table container is capable of rendering.
|
Hi @njalerikson, This looks really nice! Some people have been asking for this. (I think the pgcli developers would like something like this for rendering the query output. On top of that, one of the developers wanted a way to select a cell, edit the content, and save it again. Further, this would require some kind of scrolling. I guess that can be implemented on top of this.) I still need to go through all the changes, but I will have some feedback. Before merging it, we have two options. Either we give this pull request some time for it to become stable and mature, or we release it as a separate package until the API is stable, and can be merged. (I don't like to introduce too many backwards-incompatible changes in prompt_toolkit, but at the same time I want code to be really nice before merging it.) Anyway, thanks a lot for starting this! Jonathan |
So I am currently pretty pleased with how the widths are handled. It works wonderfully when using weighted widths and/or fixed widths. What I currently dislike is that there isn't a way to handle a "fitted" width where a column width is governed exclusively by the preferred width value and not expanded to fill the screen (as currently happens). How do you think that could be best accomplished? I would expect a table where all of the columns are being "fitted" could potentially result in a table that doesn't fill the screen width. Finally, I think that there should be a different way of solving the need to override the Maybe it makes more sense to modify |
2abbf7d
to
548a99e
Compare
@jonathanslenders what steps are required for this PR to be merged? Maybe I can help |
At least:
I never had the time to review it, but given that it doesn't change any code outside of this file, if all works well and the above is fixed, maybe it can be merged. |
are there still people working on this? |
Hi @Vosjedev in the past I started working on a different approach for the same solution. I started creating If anyone wants to continue where I left it I can transfer the repo or accept PR |
I am aware that this PR is not finished yet. I want to get community feedback to see if there are any preferred ways of implementing this.The implementation thus far works in generating a table.
Still need to figure out the ideal way of controlling column widths.A demo of the container is available as part of this PR:
I was initially thinking to use the width logic used byprompt_toolkit.shortcuts.progressbar.ProgressBar
but I don't think that will work given the desire to support merged cells.The column widths are controlled by the
column_width
andcolumn_widths
arguments passed to theTable
container.column_width
is the defaultDimension
to use for all widths,column_widths
is the index specificDimension
. If the column width for a given column isNone
then we aggregate all of the cells in that column together and get the "maximum"Dimension
, otherwise we use the column width defined.#305