tkinter按钮bind错误

问题描述

所以我想将Enter按钮绑定到该功能,因此当我按下带有Enter按钮的按钮时它将起作用。 但是,每次我这样做的时候,按钮总是有一个奇怪的错误,有时它总是处于按下状态,或者有时按钮充当我在代码中编写一个前台活动参数。

我总是这样写

def itung():
   import speedtest
   st = speedtest.Speedtest()
   lbl['text']=round(st.download/1000000,2)

lbl= Label(root,width=5,height=3)
lbl.place(x=n,y=n)#n here is just an example
btn = Button(root,text='tombol',bg='brown',fg='yellow')
btn.place(x=n,y=n)#n here is just an example
btn.bind('<Return>',itung)

那么有人可以帮我吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)