![](/img/trans.png)
[英]How can I delete a Tkinter StringVar character by character in Python?
[英]How can I pass the press of a character to a function? Python, Tkinter
function 必须接受三个变量,我不知道如何通过按钮单击
root.bind("<Key>", position(event= , x_global=x_global, y_global=y_global))
bind 的基本语法是widget.bind(event,func)
对于 ButtonPress,它是widget.bind('<Button>',func)
其中 func 是要调用的 function 的地址/id。 不使用 lambda,例如
没有参数/'变量'
def func(e): #e is the event that is passed to func by the bind function
pass
widget.bind('<Button>',func)
3个参数
from functools import partial
def func(e,fx,fy,fz):
pass
x=1
y=2
z=3
widget.bind('<Button>',partial(func, fx=x,fy=y,fz=z))
partial
是一个方便的 functools function,它允许将参数/变量与 func id 参数一起传递给绑定调用的 function。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.