i have created lines in graphwin but i did it the long way is there a simpler way using loops ?
cheers

``````def drawlines():
win = GraphWin("lines", 200, 200)

line = Line(Point(100, 100), Point(200, 200))
line1 = Line(Point(100, 100), Point(150, 200))
line2 = Line(Point(100, 100), Point(100, 200))
line3 = Line(Point(100, 100), Point(50, 200))
line4 = Line(Point(100, 100), Point(0, 200))
line5 = Line(Point(100, 100), Point(200, 0))
line6 = Line(Point(100, 100), Point(200, 50))
line7 = Line(Point(100, 100), Point(200, 100))
line8 = Line(Point(100, 100), Point(200, 150))

line0 = Line(Point(100, 100), Point(100, -50))
line10 = Line(Point(100, 100), Point(-50, 100))
line20 = Line(Point(100, 100), Point(150, -50))
line30 = Line(Point(100, 100), Point(-50, 150))
line40 = Line(Point(100, 100), Point(-50, 50))
line50 = Line(Point(100, 100), Point(50, -50))
line60 = Line(Point(100, 100), Point(-200, -200))

line.draw(win)
line1.draw(win)
line2.draw(win)
line3.draw(win)
line4.draw(win)
line5.draw(win)
line6.draw(win)
line7.draw(win)
line8.draw(win)
line0.draw(win)
line10.draw(win)
line20.draw(win)
line30.draw(win)
line40.draw(win)
line50.draw(win)
line60.draw(win)

drawlines()``````
3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by vegaseat

It appears that the first point is constant. Create a list of second point objects, then iterate on the list.

``````pointList = [Point(200, 200),
Point(150, 200),
...............
]
for pt in pointList:
Line(Point(100, 100), pt).draw(win)``````

managed to get that to work thanks. is there a way to make the lines change colour by user input? tried a few ways but nothing seemed to work.

Note: this should be a regular post, not a code snippet post!

Code Snippets are for finished code.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.