Пример из интернтера, как в tkinter рисуют треугольник
import random
from tkinter import Tk, Button, Canvas, PhotoImage
def putpixel(x, y):
x = int(x * 100 + 100)
y = int(y * 100 + 100)
image.put("white", to=[x, y])
def draw_serp():
x = random.random()
y = random.random()
for step in range(1500):
choice = random.choice(["top", "left", "right"])
if choice == "top":
x1 = x * 0.5
y1 = y * 0.5 + 0.5
elif choice == "left":
x1 = x * 0.5 - 0.5
y1 = y * 0.5
elif choice == "right":
x1 = x * 0.5 + 0.5
y1 = y * 0.5
x = x1
y = y1
if step > 50:
putpixel(x, y)
root = Tk()
canvas = Canvas(root, width=199, height=199, background="black")
image = PhotoImage(width=200, height=200)
canvas.create_image(0, 0, image=image, anchor="nw")
canvas.pack()
button = Button(root, text="Draw", command=draw_serp)
button.pack()
root.mainloop()