Creating an animation showing a line dropping vertically using wxPython

I wrote a code showing a line dropping vertically using wxPython. The issue Iam facing is when I keep the same y-coordinate (y2=y4 :drawing horizontal line on frame), the line is not visible on the window.

If I change the 4th parameter of the DrawLine(...) call by 1 unit (size[1]/2 -300+i*10 => size[1]/2 -301+i*10), the line is visible.

Can anyone explain where Iam going wrong.

My code where I kept same y-coordinate to draw horizontal line is below. In this case, line is not visible.

import wx;
import time;

app = wx.App();
frame=wx.Frame(None,-1,'Line');
frame.SetBackgroundColour('White');
frame.Centre();
frame.Show();
frame.Maximize();
dc=wx.ClientDC(frame);
size=dc.GetSize();
for i in range(1,50):
    dc.SetPen(wx.Pen('VIOLET'));
    dc.DrawLine(size[0] / 2-500, size[1]/2-300+i*10, size[0] / 2 , size[1]/2 -300+i*10);
    time.sleep(0.2);
    dc.SetPen(wx.Pen('WHITE')); # the pen is set to white and same line is drown to create the animation
    dc.DrawLine(size[0] / 2-500, size[1]/2-300+i*10, size[0] / 2 , size[1]/2 -300+i*10);
app.MainLoop();

Now, if I change y-coordinate by even by 1 unit (y4=y2+1), the line is visible and the animation is shown on the frame. The code is below

import wx;
import time;

app = wx.App();
frame=wx.Frame(None,-1,'Line');
frame.SetBackgroundColour('White');
frame.Centre();
frame.Show();
frame.Maximize();
dc=wx.ClientDC(frame);
size=dc.GetSize();
for i in range(1,50):
    dc.SetPen(wx.Pen('VIOLET'));
    dc.DrawLine(size[0] / 2-500, size[1]/2-300+i*10, size[0] / 2 , size[1]/2 -301+i*10);
    time.sleep(0.2);
    dc.SetPen(wx.Pen('WHITE')); # the pen is set to white and same line is drown to create the animation
    dc.DrawLine(size[0] / 2-500, size[1]/2-300+i*10, size[0] / 2 , size[1]/2 -301+i*10);
app.MainLoop();

Can anyone explain why this difference or where Iam going wrong?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum