循环点击

时间:2016-07-08 01:03:24

标签: python graphics

设计一个控制图形窗口,只要单击该窗口就需要重复它。

以下是要重复的对象的代码

# Limit the bounds of the buttons
def moveBob():
    if 80<x<120 and 10<y<50:
        moveForward= Bob.move(0,-20)
    if 80<x<120 and 100<y<140:
        moveBack= Bob.move(0,20)
    if 25<x<65 and 55<y<95:
        moveLeft= Bob.move(-20,0)
    if 135<x<175 and 55<y<95:
       moveRight= Bob.move(20,0)

这是&#34;代码&#34;我需要做的重复

point= Control.getMouse()
x= point.getX()
y= point.getY()
while click: #need a while loop that will repeat on click
    moveBob

只要用户点击

,我就需要一种方法来重复此代码

更新

将语句移动到while循环中解决了它,即:

while True:
    point= Control.getMouse()
    x= point.getX()
    y= point.getY()
    moveBob()

1 个答案:

答案 0 :(得分:0)

将语句移动到while循环中解决了它,即:

while True:
    point= Control.getMouse()
    x= point.getX()
    y= point.getY()
    moveBob()