我有两个函数是Python 3.4.1 Tkinter GUI的一部分。
def jumpto():
global jump
jump = Tk()
jump.wm_title("Jump")
jump.focus_force()
label = Label(jump, text = "Enter digit to jump:").pack()
global jumptext
jumptext = IntVar()
jumpentry = Entry(jump, textvariable = jumptext)
jumpentry.pack()
jump.bind("<Return>", close)
def close(self):
global jumptext
global jump
print(jumptext.get())
while digit < jumptext.get(): #digit is an integer that increases in the unrelated area below
#Do something completely unrelated
jump.destroy()
jButton = Button(master, text = "JUMP", command = jumpto).pack() #master is the main Tk window
但是,当我运行代码时,jumptext.get()
中的close
仍然为0,尽管在使用jumpentry
创建的输入框中输入了某些内容。有何方法使输入的信息实际更新为jumptext.get()
?
此外,如果有人可以向我解释为什么必须在self
内输入close
,那将是一个奖励。
提前致谢!