我对Python还不熟悉。
我试图让游戏开始,当按钮"pull"
被点击。
但是我有,游戏从我点击win
的任何地方开始
from graphics import*
from random import*
from time import*
def main():
# Creating the window
win = GraphWin("Clay Target Control Panel",400,400)
# "Pull" rectangle and color
pullrec = Rectangle(Point(150,290),Point(250,330))
pullrec.setFill("light salmon")
pullrec.draw(win)
pullmess = Text(Point(200,310),"PULL")
pullmess.setSize(11)
pullmess.setStyle("bold")
pullmess.draw(win)
# Start the game when "Pull" rectangle is clicked.
while True:
mouse = win.getMouse()
if pullrec:
win.getMouse()
我怀疑win.getMouse会阻塞,等待鼠标单击
pullrec
绑定到一个矩形bool(<rectangle>)
是True
,所以if rectangle
总是激发。您需要调用一些方法来查看鼠标单击的位置。我知道如何使用tkinter
,但不知道graphics
相关问题 更多 >
编程相关推荐