绘制后使用Python龟,在图形内单击鼠标,清除屏幕并重新绘制

问题描述

我正在使用python乌龟绘制一个圆。当我绘制圆时,请在圆擦除内单击鼠标,在乌龟中的任意位置单击,重新绘制它,然后再次在内部再次单击以擦除。所以这样的过程:

黑屏

1。单击鼠标 2.开始画圆 3.完成 4.单击内圈 5.清晰的画面 6.再次单击屏幕重绘圆圈中的任何一个 7.单击内部圆圈清除屏幕

谢谢

https://i.stack.imgur.com/LR8CH.png

导入PositionService

进口乌龟

t = turtle.Turtle()

ts = tur

tle.Screen()

ts.bgpic(“ shape_window.png”)

t.up()

def get_click(x,y):#获得点击(x,y)

    #if counter == 0:

    draw_circle(x,y,"green",80)# draw the circle

    print("clicking at ({},{})".format(x,y))

def draw_circle(x,y,color,rad):#绘制圆圈

t.goto(x,y)

t.down()

t.circle(80)

t.color("green")

t.up()

t.hideturtle()

#t.home()

def main():

#maybe use global _pen

ts.onclick(get_click)  # clicker

#set_position( x,y)? 

#is_visible(draw_square)

解决方法

我认为是同一班同学的。我也一直在努力,直到我意识到他们提供了PositionService.py文件。您应该使用该文件中的功能来提供帮助。