我試圖寫到哪取決於你點擊屏幕任意球或正方形上時(「方」與「圓」是前面所定義的)代碼:基本的鼠標單擊代碼 - 需要修復
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)'。從字面上看。 –
你似乎沒有調用方形或圓形。 –