prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.39k stars 716 forks source link

Data grid / table #305

Open tony opened 8 years ago

tony commented 8 years ago

With a fix set of columns / dynamic number of rows, is there any proof of concepts out there for handling a tabular data?

jonathanslenders commented 8 years ago

No, sorry. Right now, there is no proof of concept of this... I keep this issue open as a reminder for when I'm going to create more examples.

therden commented 8 years ago

@tony: Are you inquiring only about displaying tabular data -- or about displaying an editable data table -- using prompt_toolkit? (Just curious...)

tony commented 8 years ago

displaying

swapniljariwala commented 6 years ago

Even I want something like this for one of my side project. I'll share the code if I complete this piece.

jonathanslenders commented 6 years ago

@swapniljariwala, if you want to try. Start from the prompt_toolkit 2.0 branch. (that should be easier and will be released soon.) I think you have to implement a custom FormattedTextControl with custom key bindings. The scrolling can be done by wrapping it in a Window.

decentral1se commented 6 years ago

Would https://github.com/nirum/tableprint cover your use case?

zokrezyl commented 1 month ago

you can use https://rich.readthedocs.io/en/stable/tables.html

  1. create rich.Console with StringIO output buffer
  2. print the tabel to the console
  3. get the vale of the buffer (buffer.get_value())
  4. render it to terminal with an ANSI object