用法:
turtle.onclick(fun, btn=1, add=None)
turtle.onscreenclick(fun, btn=1, add=None)
- fun:- 具有兩個參數的函數,將使用畫布上單擊點的坐標調用
- btn:- mouse-button 的編號,默認為 1(鼠標左鍵)
- add:-
True
或者False
- 如果True
, 將添加新的綁定,否則將替換以前的綁定
參數:
將
fun
綁定到此屏幕上的 mouse-click 事件。如果fun
是None
,則刪除現有綁定。一個名為
screen
的 TurtleScreen 實例和一個名為turtle
的 Turtle 實例的示例:>>> screen.onclick(turtle.goto) # Subsequently clicking into the TurtleScreen will >>> # make the turtle move to the clicked point. >>> screen.onclick(None) # remove event binding again
注意
此 TurtleScreen 方法僅在名稱
onscreenclick
下可用作全局函數。全局函數onclick
是從 Turtle 方法onclick
派生的另一個函數。
相關用法
- Python turtle.onclick()用法及代碼示例
- Python turtle.onkey用法及代碼示例
- Python turtle.onscreenclick()用法及代碼示例
- Python turtle.onrelease用法及代碼示例
- Python turtle.ontimer用法及代碼示例
- Python turtle.onkeypress用法及代碼示例
- Python turtle.onrelease()用法及代碼示例
- Python turtle.ondrag()用法及代碼示例
- Python turtle.ontimer()用法及代碼示例
- Python turtle.onkey()用法及代碼示例
- Python turtle.write_docstringdict()用法及代碼示例
- Python turtle.reset用法及代碼示例
- Python turtle.delay()用法及代碼示例
- Python turtle.write()用法及代碼示例
- Python turtle.getpen()用法及代碼示例
- Python turtle.isvisible用法及代碼示例
- Python turtle.tracer用法及代碼示例
- Python turtle.end_fill()用法及代碼示例
- Python turtle.undo用法及代碼示例
- Python turtle.speed()用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 turtle.onclick。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。