美文网首页
c04ex01.pyw

c04ex01.pyw

作者: 特丽斯纳普 | 来源:发表于2018-03-29 16:37 被阅读0次

c04ex01.pyw

Drawing with square bricks

from graphics import *

def main():
win = GraphWin()
shape = Rectangle(Point(40,40), Point(60,60))
shape.setOutline("red")
shape.setFill("red")
shape.draw(win)
for i in range(10):
p = win.getMouse()
c = shape.getCenter()
dx = p.getX() - c.getX()
dy = p.getY() - c.getY()
shape = shape.clone()
shape.move(dx,dy)
shape.draw(win)
Text(Point(100,180), "Click again to quit.").draw(win)
win.getMouse()
win.close()

main()

相关文章

  • c04ex01.pyw

    c04ex01.pyw Drawing with square bricks from graphics impo...

网友评论

      本文标题:c04ex01.pyw

      本文链接:https://www.haomeiwen.com/subject/nktvcftx.html