How to eliminate flicker?

Good afternoon. I am writing a program that highlights moving objects in a video. I select objects with a picture. But on the video, my picture is flickering. How to eliminate flicker?

My code


Flicker happens when that portion of the screen is drawn multiple times with enough time between the draws that the user is able to perceive the different content of the drawing. The typical way to overcome that is to first draw the content to a bitmap, and then draw that bitmap to the screen. That way there is only one draw per paint event. This is called double-buffering.

On OSX and GTK3 the system does double-buffering internally, so there really isn’t much reason to do it yourself. If you’re on Windows then flicker is still an issue that needs to be considered, but you can tell the system to double-buffer a window by calling SetDoubleBuffered.

Depending on how the video is being shown, double buffering may not help. (Probably not, actually.) More details about this may help us help you. Also, please always mention the platform and wxPython version.

Thank. I solved the problem by setting the variable to true