Skip to content

Flow layout or table (question/request) #1436

@altendky

Description

@altendky

Hi, I am experimenting with a move from curses to prompt_toolkit (and some rich) and having fun so far. One thing that I need to present to the user is a bunch of pairs of data. They are paths and the free space on the associated disk. It is presently output as follows and adjusts the number of 'cells' on each row based on the overall width of the terminal.

001:   24GB | 003:   25GB | 005:   38GB | 007:   66GB | 009: 9998GB |  |
002:   24GB | 004:   25GB | 006:   66GB | 008: 8256GB |             |  |
001:   24GB | 002:   24GB | 003:   25GB | 004:   25GB | 005:   38GB | 006:   66GB | 007:   66GB | 008: 8256GB | 009: 9998GB

It is not working beautifully or anything, but I share it to show one view of the idea. In general, I think the term 'flow layout' would be appropriate for what I want here. Or, alternatively, flowing the data through cells in a table. It might even be able to be viewed as a wrap feature with some control over exactly where the wrap can occur. Either way, there's a back and forth of sorts between the data size and the terminal size. The first few seconds of https://www.youtube.com/watch?v=pDqjHozkMBs show a flow layout. Note, I am a Qt/Python GUI dev significantly, not Java, but this video turned up quickly.

Does prompt_toolkit have any existing features to manage this? As mentioned, I can imagine that could be in the form of an ability to flow, an ability to control wrap points, or even just the ability to sensibly check the Window() width available for the content prior to creating the content and then I can manage the flow. The last point seems the simplest in terms of the demands on prompt_toolkit but I wasn't sure if there were caveats about doing that in combination with .invalidate() or similar potentially getting a different terminal size when they execute. That wouldn't be the end of the world, but if I can learn the proper way to handle the situation, that would be nice.

Thanks for any help you can offer to get me in the proper mindset to solve this well within the prompt_toolkit framework. For reference, my efforts are available at ericaltendorf/plotman#299 and can be run via the plotman prompt_toolkit command. Though, I don't actually expect anyone to run it. :]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions