我正在使用python turtle绘制圆圈。当我绘制圆圈时,鼠标单击圆圈内部擦除,单击乌龟中的任何位置,重新绘制它,然后再次单击内部擦除。所以这个过程是这样的:
黑屏
1.单击鼠标2.开始画圆3.饰面4.点击圆圈内部5.清除屏幕6.再次单击屏幕中的任意wehre重新绘制圆圈7.点击圆圈内清除屏幕
感谢
https://i.stack.imgur.com/LR8CH.png
导入PositionService
进口海龟
t=海龟。海龟((
ts=tur
tr.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文件。您应该使用该文件中的函数来提供帮助。