I'm using Spyder 3.2.6 ... added mywindow.update() inside the loop

# my code
import tkinter as tk
import time

mywindow = tk.Tk()
mywindow.minsize(width=600,height=600)

mycanvas = tk.Canvas(mywindow, width=500, height=500, background = "yellow")
mycanvas.place(x=50, y = 0)

startx = 1

for i in range (1,500,10):
    mycanvas.create_line(startx,100,i,100 )
    startx = i
    time.sleep(0.010)
    mywindow.update()

tk.mainloop()


On Tue, Jan 12, 2021 at 7:36 PM mukund athavale <[email protected]>
wrote:

> Hi,
>
> I want to draw a line on screen so that it gets displayed *slowly* from
> left to right.
> The line is not drawn point by point after the sleep time interval. The
> line appears suddenly after the total time elapsed.
>
> Increasing sleep time does not help. I have also tried the "after" command
> but does not help.
>
> Is there any simple solution ?
>
> I have used following code.
>
> # my code
> import time
> from tkinter import *
> mywindow = Tk()
>
> mywindow.minsize( width=600,height=600)
> mycanvas = Canvas(mywindow, width=500, height=500, background = "yellow")
> mycanvas.place(x=50, y = 0)
>
> startx = 1
>
> for i in range (1,500,10):
>     mycanvas.create_line(startx,100,i,100 )
>     startx = i
>     time.sleep(0.010)
>
> mc.mainloop()
>
> Mukund Athavale
> Mumbai, India
>
> --
> You received this message because you are subscribed to the Google Groups
> "spyder" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/spyderlib/443ef185-536e-4f4d-8029-a112ba4007abn%40googlegroups.com
> <https://groups.google.com/d/msgid/spyderlib/443ef185-536e-4f4d-8029-a112ba4007abn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/spyderlib/CAGGyJTpWj2VDtTz-x_k%2BZ7c4d%2B9AnA_VoCfWfubzqfs1dz6UFA%40mail.gmail.com.

Reply via email to