Hi guys.. Im stuck on my project and i urgently need ur help.
i want to randomly generate some moving rectangles (one after another moving in the same direction). this should occur infinitely. So far i have only managed to create one moving rectangle.

i hope u guys can help me out plz
thanks..

import <strong class="highlight">Tkinter</strong> as tk
import time

root = tk.Tk()

canvas = tk.Canvas(root, width=400, height=400)
canvas.pack()

# canvas.create_rectangle(x0, y0, x1, y1, option, ... )
# x0, y0, x1, y1 are corner coordinates of ulc to lrc diagonal
rc1 = canvas.create_rectangle(20, 260, 120, 360, outline='white', fill='blue')
rc2 = canvas.create_rectangle(20, 10, 120, 110, outline='white', fill='red')

for x in range(50):
    y = x = 5
    time.sleep(0.025)
    canvas.move(rc1, x, -y)
    canvas.move(rc2, x, y)
    canvas.update()

root.mainloop()

any help please?? at least some clues how to do it will be appreciated.. thanks

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.