Skip to content
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

[REQUEST] Allow the pager to *stream* console output #2962

Closed
Jackenmen opened this issue May 14, 2023 · 3 comments
Closed

[REQUEST] Allow the pager to *stream* console output #2962

Jackenmen opened this issue May 14, 2023 · 3 comments

Comments

@Jackenmen
Copy link
Contributor

How would you improve Rich?

I would like for it to be possible for me to page the console.printed input as soon as console.print() is called. This would help with paging text as it is received when you, for example, fetch multiple things from an API or when you're streaming output from some long-running program.

Example:

import subprocess

with console.pager():
    with subprocess.Popen(["du", "/"], stdout=subprocess.PIPE, text=True) as proc:
        for line in proc.stdout:
            console.print(line)

Note that I'm just reusing the existing API in this example but that doesn't mean it necessarily should be that same API.

What problem does it solve for you?

It allows me to immediately show part of the output to the user while the program is fetching the rest of the data, as opposed to the user having to wait for all data to be available which could take a lot longer.

@github-actions
Copy link

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@willmcgugan
Copy link
Collaborator

This is probably more of the remit of Textual (https://github.com/Textualize/textual). Not something that could be easily added to Rich.

@github-actions
Copy link

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants