Ask coding questions

← Back to all posts
Prevent screen flickering/paint over screen
[deleted]

When I use a clear function (that I made so I can use in windows + linux), it flickers the screen, and is unbearable. Im wondering if there is a way to prevent the screen from flickering, or paint over the screen (stackoverflow told me to do this, but I dont know how.)

Answered by pyelias (2715) [earned 5 cycles]
View Answer
Comments
hotnewtop
pyelias (2715)

Screen flickering happens when your program output gets split up and doesn't all arrive in your browser at the same time. To force it to be sent all at once, you can use code like this.

[deleted]

@pyelias going to look into it, but this seems like using an ansi escape code

pyelias (2715)

@TaylorLiang It is, does that cause any problems?

[deleted]

@pyelias not really, not really that portable, but Ill use it!

HarperframeInc (456)

When you clear, your adding a bunch of '\n' lines quickly. The computer can't do it instantly, so you have screen flickering. I'm sorry, but I don't think you can fix this.

However, if you want to at least slow the process down, you shouldn't use a while loop and clear at the same time. Slow it down by using time.sleep(seconds).