【发布时间】:2018-08-12 07:12:15
【问题描述】:
我已经阅读了 Stackoverflow 上关于这个错误的几篇帖子以及与之相关的问题:所以这个函数不是类方法,脚本中没有重复等。它是一个 tkinter 偶数驱动函数。我在另一个帖子上看到了类似的,我试过了,它有效,但我的没有,我不知道为什么。
如果您没有什么要说的,请不要发表明智的言论,否则在此先感谢您的帮助。
为清楚起见,我将上下文简化为最基本的内容:
from tkinter import *
w = Tk()
def initializeVars():
global extRequired, Keyword, filePath
## extRequired = text1.get()
## Keyword = text2.get()
## filePath=BaseDir+AllFiles
print('initializing variables')
def func(event):
print("You hit return.")
w.bind('<Return>',initializeVars)
# Buttons
Button(text='Select Folder', command=initializeVars).grid(row=10,column=2)
w.mainloop()
如您所见,我正在尝试将initializeVars 函数绑定到键盘的返回键。
【问题讨论】:
标签: python python-3.x tkinter