magmax/python-inquirer

List options wont clear from screen after selected.

Opened this issue · 3 comments

I am trying to prompt the user for multiple questions using inquirer.List. I am able to select the items but the options wont clear away when asking for the next one.

>>> inquirer.prompt(questions);inquirer.prompt(questions)                        
[?] What size do you need?: Large
   Jumbo
 > Large
   Standard
   Medium
   Small
   Micro

[?] What size do you need?: Medium
   Jumbo
   Large
   Standard
 > Medium
   Small
   Micro

Is it possible to clear the options like inquirer.js does?

AuHau commented

I am afraid there is no support for this feature at this moment.

This can achieved by adding

print(self.terminal.home + self.terminal.clear, end="")

before this, however this could come with potential side effects.

Thanks for this awesome package! I was running into this problem yesterday, and I've customize a component to solve it after digging into source code.
You can check it out here: https://gist.github.com/NaleRaphael/64acf6404aeab749ae335a457d842c95

The idea of this implementation is that we have to know have many lines have been printed, and then we can move the cursor to that line and clear those lines under it. (with the help of blessed.Terminal().move_up() and blessed.Terminal().clear_eol())

And also thanks for the advice from @mauricesvp. But since it will clear the whole history (printed lines) in current terminal, I have to give up on it.