prompt-toolkit / prompt-toolkit/python-prompt-toolkit
python-prompt-toolkit 2.0 rerun _(event) until different key is pressed
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
do you know if there is a simple solution to rerun the event in a loop but still be able to switch on key press?
for example
from prompt_toolkit import Application
from prompt_toolkit.key_binding import KeyBindings
import random
@kb.add('a')
def _(event):
" Do something if 'a' has been pressed. "
os.system('clear')
print(‘you pressed a key’)
print_formatted_text(random.randint(0,100))
@kb.add('u')
def _(event):
" Do something if 'u' has been pressed. "
print(‘you pressed u key’)
print_formatted_text(random.randint(0,100))
app = Application(key_bindings=kb, full_screen=True)
with patch_stdout():
app.run()
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Application, KeyBindings, and app.run entry points used in the example, focusing on how key handlers return control to the application. Determine whether repeated work can continue while another key remains dispatchable, and verify that pressing a different key interrupts the repetition and invokes its handler.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100