tkinter canvas create_rectangle
from tkinter import * import random tk=Tk() canvas=Canvas(tk, width=400,height=400) canvas.pack() def random_rectangle(width,height,fill_color): x1=random.randrange(width) y1=random.randrange(height) x2=random.randrange(x1+random.randrange(width)) y2=random.randrange(y1+random.randrange(height)) if abs(x1-x2)*abs(y1-y2)>20000: return if abs(x1-x2)