From 132e890ca7a34558114378d2ea451bc58184348a Mon Sep 17 00:00:00 2001 From: clothespin Date: Tue, 16 Mar 2021 17:44:14 -0700 Subject: [PATCH] Adds prompt_toolkit inputhook using helper func since kwarg was removed --- gamestonk_terminal/menu.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gamestonk_terminal/menu.py b/gamestonk_terminal/menu.py index c6455b7cc2e..8f616138a72 100644 --- a/gamestonk_terminal/menu.py +++ b/gamestonk_terminal/menu.py @@ -3,11 +3,18 @@ import os from matplotlib import pyplot from prompt_toolkit import PromptSession +from prompt_toolkit.eventloop.inputhook import set_eventloop_with_inputhook from prompt_toolkit.history import FileHistory +def inputhook(inputhook_context): + while not inputhook_context.input_is_ready(): + pyplot.pause(0.1) + return False + history_file = os.path.join(os.path.expanduser("~"), ".gamestonk_terminal.his") try: - session = PromptSession(history=FileHistory(history_file), inputhook=pyplot.draw) + session = PromptSession(history=FileHistory(history_file)) + set_eventloop_with_inputhook(inputhook) except Exception as e: # noqa: F841 - session = None + raise e