Open ninest opened 4 years ago
It is not possible to call prompt()
within a key binding, because that would spawn a new event loop.
Instead, the key binding should return the result. event.app.exit(result=...)
and the place where prompt()
was called in the first place should handle the outcome and spawn a new prompt accordingly.
Also, remember that a for-loop does not create a scope, so the value of "i" will always be 9 for each of the key bindings in the above code.
I'll show this issue with a small example and error I get. I'm making a notes CLI app where first the user is presented with a list of notes. They can enter a number (0-9) to go to the specific note. Once they are in the note, there's a timer for 1 second. Once this timer is complete, they will go back to the main page, where they can see all the notes again.
Here's the code:
The code works fine until I want to show the main screen after 1 second in the notes page. The error I get is:
I believe this is because I am referencing the variable
kb
inside functions that are decorated by@kb.add
.Is there a way to fix this?