#!/usr/bin/env python3""" turtle-example-suite:tdemo_paint.pyA simple event-driven paint program- left mouse button moves turtle- middle mouse button changes color- right mouse button toggles between pen up(no line drawn when the turtle moves) andpen down (line is drawn). If pen up followsat least two pen-down moves, the polygon thatincludes the starting point is filled.-------------------------------------------Play around by clicking into the canvasusing all three mouse buttons.-------------------------------------------To exit press STOP button-------------------------------------------"""from turtle import *def switchupdown(x=0, y=0):if pen()["pendown"]:end_fill()up()else:down()begin_fill()def changecolor(x=0, y=0):global colorscolors = colors[1:]+colors[:1]color(colors[0])def main():global colorsshape("circle")resizemode("user")shapesize(.5)width(3)colors=["red", "green", "blue", "yellow"]color(colors[0])switchupdown()onscreenclick(goto,1)onscreenclick(changecolor,2)onscreenclick(switchupdown,3)return "EVENTLOOP"if __name__ == "__main__":msg = main()print(msg)mainloop()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。