Python + Blessed: how to avoid the flickering when clearing the screen very frequently

2.2k views Asked by At

What I am doing

Versions: Linux + Python 2.7 + Blessed 1.14.1

I have text strings continuously updating on terminal. Refresh rate is about 0.1 seconds.

They have different size and I clear the screen before printing back all the current values.

Problem

The terminal flickers when Terminal.clear() is called so often.

Possible (ugly) solution

I could pad each line to have fixed length and overlap it on the old text, but this is not elegant. I would imagine there is a better way to accomplish this.

EDIT

Pending a term.clear_eol (clear till end of line) is far more efficient than pad each line with blanks:

print(term.bold_white_on_red("text") + term.clear_eol)

Off course print(term.clear()) at the beginning must be removed to avoid the flickering.

Question

In curses I could use curses.erase() instead of curses.clear(), but I couldn't find any erase() in Blessed. Is there any other (obvious) solution that I am overlooking?

(PS: I already read all available docs. While I know quite a bit of curses I would like to start using Blessed because it is far easier.)

0

There are 0 answers