[英]Unable to display coordinates after polygon drawn in Zelle graphics.py
能夠在Python中使用Zelle graphics.py成功繪制多邊形,但無法顯示所用點的坐標。 我如何僅使用getPoints()完成它。
這是我的代碼:
import math
import graphics #must be included
from graphics import* # must be included
def main():
win = graphics.GraphWin("Exercise 2, Polygon", 500, 500)
#denotes window size
win.setBackground("black")
polygon = Polygon(Point(60,80),Point(50,70),Point(70,20),Point(90,50),Point(100,80))
#Include "Point" in the statement, else it wouldn't work
polygon.setOutline("yellow")
polygon.setWidth(5)
polygon.draw(win)
main()
您可以在主方法中簡單地使用print(polygon.getPoints())
進行此操作,該方法將為您提供[Point(60.0, 80.0), Point(50.0, 70.0), Point(70.0, 20.0), Point(90.0, 50.0), Point(100.0, 80.0)]
print(polygon.getPoints())
[Point(60.0, 80.0), Point(50.0, 70.0), Point(70.0, 20.0), Point(90.0, 50.0), Point(100.0, 80.0)]
作為輸出。
import math
import graphics #must be included
from graphics import* # must be included
def main():
win = graphics.GraphWin("Exercise 2, Polygon", 500, 500)
#denotes window size
win.setBackground("black")
polygon = Polygon(Point(60,80),Point(50,70),Point(70,20),Point(90,50),Point(100,80))
#Include "Point" in the statement, else it wouldn't work
polygon.setOutline("yellow")
polygon.setWidth(5)
polygon.draw(win)
print(polygon.getPoints())
main()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.