0

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()
1
Contributor
1
Reply
3
Views
8 Years
Discussion Span
Last Post by harrykokil
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.