Skip to main content

St. Nicholas' House

The turtle (from the Tkinter library) allows you to create simple to complex graphics on screen using Python. It is controlled with understandable commands like forward, left, right, etc. Older programmers already know it from Logo (1967), COMAL (1973), etc. - younger programmers know something similar from Scratch (2007) with the so-called “pen”.

St. Nicholas
flowchart TD
    A[Start] --> B[Initialize Turtle and Window]
    B --> C[Set House Parameters a, x, y]
    C --> D[Set Turtle Settings: Shape, Speed, Pen Width]
    D --> E[Draw Base: teleport to x, y]
    E --> F[Draw Line to x+a, y]
    F --> G[Draw Line to x, y+a]
    G --> H[Draw Line to x+a, y+a]
    H --> I[Draw Line back to x, y]
    I --> J[Draw Line to x, y+a]
    J --> K[Draw Roof Peak: to x+a/2, y+a+a/2]
    K --> L[Draw Line to x+a, y+a]
    L --> M[Draw Line to x+a, y]
    M --> N[Hide Turtle]
    N --> O[End Program]
# https://docs.python.org/3.13/library/turtle.html
import turtle  # Bestandteil von tkinter

# Hausparameter
a = 100  # Seitenlänge der Grundfläche in Pixel
# Startposition (unten links)
x, y = 0 - a/2, 0 - a/2  # 0,0 entspricht Mitte des Fensters

# Fenster einrichten
turtle.title("Das Haus vom Nikolaus")
turtle.setup(a * 3, a * 3)  # Fensterbreite, Fensterhöhe in Pixel
turtle.shape("turtle")  # arrow, circle, ...
turtle.speed(3)  # 0 = sofort, 1 - 10 sehr schnell => help(turtle.speed)
turtle.pensize(3)

# Zeichnen
# turtle.penup()
# turtle.goto(x, y)
# turtle.pendown()
turtle.teleport(x, y)
turtle.goto(x + a, y)
turtle.goto(x, y + a)
turtle.goto(x + a, y + a)
turtle.goto(x, y)
turtle.goto(x, y + a)
turtle.goto(x + a / 2, y + a + a / 2)
turtle.goto(x + a, y + a)
turtle.goto(x + a, y)

# Programmende
turtle.hideturtle()
turtle.done()