Hi there,
I am trying to repeat my triangle on 100px by 100px;

Any help is much appreciated.

Many thanks,


def drawTrianglePatch(win, x, y, colour):
    for i in range(5):
        for j in range(5):
            if (i + j) % 2 == 0:
                triangle = i * 20
                triangle = y + j * 20
                triangle = Polygon((Point(100,20), Point(80,60), Point(120,20)),
                Point( + 20, repeatY + 20))

Recommended Answers

All 2 Replies

You might tell us what GUI toolkit you are using.
What is repeatY in line 10?

You should be using "x" and "y" passed to the function for your start position instead of the hard coded one. You can then pass a different x, y (start) to the function, assuming you are always drawing the same size triangle. In Tkinter (which doesn't look what you are using) you can also move an object to the postion you want so perhaps your GUI has a similar function.

## the preferred way if your GUI has a similar method
goto(x ,y)

## offset the postion otherwise
triangle = Polygon((Point(x+100,y+20), Point(x+80,y+60), Point(x+120,y+20)))    
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.