[BUG] `input()` or `Prompt.ask` does not work properly with progress bars.
See original GitHub issueThe input()
/ Prompt.ask()
functionality does not render properly with the progress bars.
Specifically, the input being typed is visible for a brief second only. It then hides behind the progress bar. The input, however, is captured properly and prints without issues.
from time import sleep
from rich.progress import track
from rich.prompt import Prompt
for i in track(range(3)):
print(f"we are at: {i}")
x = input("Type something")
# x = Prompt.ask("Type something")
print(f"You typed: {x}")
sleep(1)
I tried using both input()
and Prompt.ask()
The output while using input()
is -
$ python test.py
we are at: 0
Type something
Working... โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 0% -:--:--
The output with Prompt.ask()
$ python test.py
we are at: 0
[2KType something: Working... [38;5;237mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ[0m
[35m 0%[0m [36m-:--:--[0m
Working... โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 0% -:--:--
Platform
Click to expand
What platform (Win/Linux/Mac) are you running on? What terminal software are you using?
Iโm using GNOME terminal 3.28.2 (Bash) on Ubuntu 18.04.
python -m rich.diagnose
โญโโโโโโโโโโโโโโโโโโโโโโโโโ <class 'rich.console.Console'> โโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ A high level console interface. โ
โ โ
โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ โ <console width=158 ColorSystem.TRUECOLOR> โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ
โ color_system = 'truecolor' โ
โ encoding = 'utf-8' โ
โ file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> โ
โ height = 43 โ
โ is_alt_screen = False โ
โ is_dumb_terminal = False โ
โ is_interactive = True โ
โ is_jupyter = False โ
โ is_terminal = True โ
โ legacy_windows = False โ
โ no_color = False โ
โ options = ConsoleOptions( โ
โ size=ConsoleDimensions(width=158, height=43), โ
โ legacy_windows=False, โ
โ min_width=1, โ
โ max_width=158, โ
โ is_terminal=True, โ
โ encoding='utf-8', โ
โ max_height=43, โ
โ justify=None, โ
โ overflow=None, โ
โ no_wrap=False, โ
โ highlight=None, โ
โ markup=None, โ
โ height=None โ
โ ) โ
โ quiet = False โ
โ record = False โ
โ safe_box = True โ
โ size = ConsoleDimensions(width=158, height=43) โ
โ soft_wrap = False โ
โ stderr = False โ
โ style = None โ
โ tab_size = 8 โ
โ width = 158 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
python -m rich._windows
platform="Linux"
WindowsConsoleFeatures(vt=False, truecolor=False)
pip freeze | grep rich
rich==11.0.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Keras Progbar Logger is not working as expected ยท Issue #5906
When using model.fit_generator, the progress-bar does not work as expected. As noted on StackOverflow, the following verbosity levels exist (which should beย ...
Read more >Python Progress Bar - Stack Overflow
Do I need a thread for this? I have no idea. Right now I am not printing anything while the function is being...
Read more >CLI Text styling, Progress Bars and more with Python and Click
I'll show you how easy it is to use Click for text styling, how to create beautiful and simple progress bars and also...
Read more >Asking for input (prompts) - Python Prompt Toolkit 3.0
The following snippet is the most simple example, it uses the prompt() function to ask the user for input and returns the text....
Read more >Progress Bars, Threads, Windows Forms, and You
When correctly implemented, a progress bar is a visual tool of reassurance that tells the end user that your program hasn't locked up...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Did I solve your problem?
Why not buy the devs a coffee to say thanks?
What would you suggest if the action wrapped by a progress bar isnโt controllable? Such as a program to clone a git URL that may or may not require inputs of credentials. In fact the prompt is raised by
git
and we canโt know when to pause it at.