467,091 Members | 1,274 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,091 developers. It's quick & easy.

Create this image with the graphics.py module

Bit
I want to create this shape but with a loop so it shortens down my code. This is using the Graphics.py module

Can anyone help pls

from graphics import *

def drawPatchLines():
win = GraphWin("Window",100,100)
win.setBackground('white')

#Draws the white rectangle in top left
rect = Rectangle(Point(0,0), Point(100,100))
rect.setOutline('black')
rect.setFill('white')
rect.draw(win)

#Draws the red lines
poly = Polygon (Point(0,100), Point(10,100), Point(10,90), Point(0,90))
poly.setFill('red')
poly.setOutline('red')
poly.draw(win)

poly1 = Polygon (Point(20,100), Point(30,100), Point(30,70), Point(0,70), Point(0,80), Point(20,80))
poly1.setFill('red')
poly1.setOutline('red')
poly1.draw(win)

poly2 = Polygon (Point(40,100), Point(50,100), Point(50,50), Point(0,50), Point(0,60), Point(40,60))
poly2.setFill('red')
poly2.setOutline('red')
poly2.draw(win)

poly3 = Polygon (Point(60,100), Point(70,100), Point(70,30), Point(0,30), Point(0,40), Point(60,40))
poly3.setFill('red')
poly3.setOutline('red')
poly3.draw(win)

poly4 = Polygon (Point(80,100), Point(90,100), Point(90,10), Point(0,10), Point(0,20), Point(80,20))
poly4.setFill('red')
poly4.setOutline('red')
poly4.draw(win)
1 Week Ago #1
  • viewed: 1432
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Steve Amey | last post: by
2 posts views Thread by Matt Silberstein | last post: by
4 posts views Thread by Arda Coskun | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.