获取输入的五个点画五边形
def pentagonUpdate(): p = {} win = GraphWin("Click", 800, 300)#后面两个值为窗体的长和宽 for i in range(5): p[i] = win.getMouse() p[i].draw(win) polygon = Polygon(p[0], p[1], p[2], p[3], p[4]) polygon.setFill("peachpuff") polygon.setOutline("black") polygon.draw(win) win.getMouse()
获取输入的两个点画直线
def GetMouseDraw(): p = {} win = GraphWin("Click me") for i in range(2): p[i] = win.getMouse() p[i].draw(win) line = Line(p[0], p[1]) line.draw(win) win.getMouse() if __name__ == '__main__': pentagonUpdate()
以上这篇python获取点击的坐标画图形的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。