我的代码如下。
代码1:
from Tkinter import *
import Tkinter as tk2
def call_second():
import tk
return
root = Tk()
E = tk2.Entry(root)
E.pack(anchor = CENTER)
B = Button(root, text = "OK", command = call_second)
B.pack(anchor = S)
root.mainloop()
代码2:
from Tkinter import *
import Tkinter as tk1
def close_window():
global entry
entry = E.get()
print entry
root1.destroy()
root1 = Tk()
E = tk1.Entry(root1)
E.pack(anchor = CENTER)
B = Button(root1, text = "OK", command = close_window)
B.pack(anchor = S)
root1.mainloop()
当我运行代码1时,按下ok按钮,它会调用第二个代码。当我关闭它并再次按下代码1上的按钮时,我无法再次调用GUI。