我目前正在python的Turtle Graphics上制作一个程序。这里是我的代码,以防您需要它Python Turtle - Click Events
import turtle
turtle.ht()
width = 800
height = 800
turtle.screensize(width, height)
##Definitions
def text(text, size, color, pos1, pos2):
turtle.penup()
turtle.goto(pos1, pos2)
turtle.color(color)
turtle.begin_fill()
turtle.write(text, font=('Arial', size, 'normal'))
turtle.end_fill()
##Screen
turtle.bgcolor('purple')
text('This is an example', 20, 'orange', 100, 100)
turtle.done()
我想要点击事件。所以,在文字'This is an example'
被写入的地方,我希望能够点击它,并将其打印到控制台或更改背景。我该怎么做呢?
编辑:
我不想安装像pygame的东西,它在龟
更新我的旧信息,用户点击任意位置时改变屏幕的色彩只有特定的文本显示区的位置按规定将改变屏幕的色彩 –