我在 Calico IDE 中使用 Graphics 和 Myro 包,任何人都可以想办法让我按下“q”键并让程序终止吗?目前,当我按下“q”键时,我必须在窗口上单击鼠标才能终止。
def main():
win = Window(800,500)
bg = Picture("http://www.libremap.org/data/boundary/united_states/contig_us_utm_zone_14_600px.png")
bg.draw(win)
while True:
char = win.getKeyPressed()
if char == 'q':
win.close()
break
x, y = win.getMouse()
MPO = Rectangle(Point(x,y), Point(x+10,y+10))
MPO.fill = Color("white")
MPO.draw(win)