Scratch to Python 25/09/2018: Malen in tkinter

Heute haben wir Kreise auf einen Canvas gemalt mit tkinter als Vorbereitung zum Malen unserer Spielfigur.

from tkinter import *
from random import *
size = 500
window = Tk()
canvas = Canvas(window, width=size, height=size)
canvas.pack()

while True:
    col = choice(['black', 'yellow', 'green', 'orange'])
    x0 = randint(0, size)
    y0 = randint(0, size)
    d = randint(0, size/5)
    canvas.create_oval(x0, y0, x0 + d, y0 + d, fill=col)
    window.update()

from tkinter import *
from random import *
size = 500
window = Tk()
canvas = Canvas(window, width=size, height=size)
canvas.pack()

while True:
    col = choice(['black', 'yellow', 'green', 'orange'])
    x0 = randint(0, size)
    y0 = randint(0, size)
    x1 = randint(0, size/2)
    x2 = randint(0, size/2)
    canvas.create_rectangle(x0, y0, x1, x2, fill=col)
    window.update()

Bonus:

Als Bonus habe ich ein Foto in tkinter reingeladen. Davor musste ich noch die Library Pillow mit folgendem Command installieren sudo pip install pillow

from tkinter import *
from PIL import ImageTk, Image
import os

root = Tk()
img = ImageTk.PhotoImage(Image.open("bild.jpg"))
panel = Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
root.mainloop()

Und jetzt das ganze auf einem Bild.

@Dschoni wie könnte ich die beiden Codes verbinden?