我试图写到哪取决于你点击屏幕任意球或正方形上时(“方”与“圆”是前面所定义的)代码:基本的鼠标单击代码 - 需要修复
def squareball(x,y):
if x <0:
square
if x >=0:
circle
canvas.onclick(squareball,2)
但是,当我点击鼠标中键没有任何反应。
我试图写到哪取决于你点击屏幕任意球或正方形上时(“方”与“圆”是前面所定义的)代码:基本的鼠标单击代码 - 需要修复
def squareball(x,y):
if x <0:
square
if x >=0:
circle
canvas.onclick(squareball,2)
但是,当我点击鼠标中键没有任何反应。
访问您的旧功能,square
和circle
。 如果他们是这样的: def <func_name>:
,插入括号,使其def <func_name>():
做或不这样做后,请square
到square()
和circle
到circle()
在if/else
声明。
摘要:你没有调用你的函数。
我得到这个错误 - TypeError:square()缺少2个必需的位置参数:'x'和'y' – Newtocode482
1.您已经用2个参数定义了'squareball',但似乎没有调用它。但是,您不在函数内部使用'y',将它从参数中移除。 2.将函数调用为func(x)'。从字面上看。 –
你似乎没有调用方形或圆形。 –