hi am writing a program and there a oval moving towards a big blue oval. i want when the red oval arrive at the blue oval is stop.can anyone tell me hoe to do this????

from Tkinter import *
import Tkinter
import time

frame=Tkinter.Frame()
frame.pack()

canvas =Tkinter.Canvas(frame,bg = 'white',width=500, height=500)
canvas.pack()


canvas.create_oval(100,450,130,480,fill="blue", outline="blue")

def progress(d,e):
    a=d
    b=e
    for i in range(0,100,10):
         a1=a+10
         b1=b+10
         time.sleep(0.5)
         canvas.create_oval(a,b,a1,b1,fill="red", outline="red")
         canvas.update()
         b=b+10
         
def want():
    c=100
    b=100
    progress(c,b)

want()
frame.mainloop()

thanks you in advance

You know where you have created your blue oval, i.e at (100,450,130,480), so just place a condition to create your red oval till you reach coordinate 450.

def progress(d,e):
    a=d
    b=e
    for i in range(0,500,10):
         a1=a+10
         b1=b+10
         time.sleep(0.5)
         print 'create at: ',a,b,a1,b1
         if (b < 450):
             canvas.create_oval(a,b,a1,b1,fill="red", outline="red")
             canvas.update()
         b=b+10

Also, there is no need of line: import Tkinter , when you have already imported all classes from that module,in the above statement, from Tkinter imort * . With this statement there is also no need to specify class name explicitly like frame=Tkinter.Frame() it is fine if you say, frame=Frame() .

BTW, what are trying to do?

katharnakh

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.