Python 错误:_tkinter.TclError:can';t调用;wm";命令:应用程序已被销毁

Python 错误:_tkinter.TclError:can';t调用;wm";命令:应用程序已被销毁,python,object,button,tkinter,command,Python,Object,Button,Tkinter,Command,我在三个不同的文件上有三个类,通过GUI获得用户输入 #file1 class GetInfo1(): def getInfo1(): #my code return info1 #file2 class GetInfo2(): def getInfo2(): #my code return info2 #file3 class GetInfo3(): def getInfo3(): #

我在三个不同的文件上有三个类,通过GUI获得用户输入

#file1
class GetInfo1():
    def getInfo1():
        #my code
        return info1
#file2
 class GetInfo2():
    def getInfo2():
        #my code
        return info2
 #file3
 class GetInfo3():
    def getInfo3():
        #my code
        return info3
从不同的文件调用这些方法
Getinformation.py
那份文件可能是

from GetInfo1 import *
from GetInfo2 import *
from GetInfo3 import *

object1 = GetInfo1()
getInfor1 = object1.getInfo1()
print getInfor1

object2 = GetInfo2()
getInfor2 = object2.getInfo2()
print getInfor2

object3 = GetInfo3()
getInfor3 = object3.getInfo3()
print getInfor3
课程如下:

from Tkinter import *

root = Tk()
app = Frame(root)

entry = Entry(app)
entry.grid()


class GetInfo1():

def OnClick(self):
    global input1
    input1 = entry.get()
    #print ("You have entered %s"%input1)
    root.destroy()
    return input1

def getInfo1(self):

    '''Window'''
    global input1
    root.title("Input Permutation Range ")
    root.geometry("300x200")
    app.grid()
    label = Label (app, text="Please Enter the propogation range ( 2 - 4)")
    label.grid()

    '''Button'''
    Object2 = AskPermutationRange()
    button = Button (app, text="Submit", command=Object2.OnClick)
    button.grid()
    root.focus_set()
    root.mainloop()
    return input1
获取指定的
getInfor1
getInfor2
,但 运行第三个对象时出错
\u tkinter.TclError:无法调用“wm”命令:应用程序已被销毁

如何再次重新调用应用程序。提前感谢

这条消息的意思是,在销毁根窗口后,您正在调用其中一个“wm”命令(例如:wm_title、wm_geometry和其他一些命令)。(注:“几何”和“标题”是“wm_几何”和“wm_标题”的简单快捷方式)


你以一种非常不寻常的方式使用tkinter。Tkinter是为创建Tk的单个实例而设计的,它只调用mainloop一次。您在申请过程中需要多次停止和启动Tkinter有什么原因吗?如果您只需要弹出一些模式对话框并等待用户输入数据,那么无需每次都创建一个新的Tk实例即可

是的,现在我得到了解决方案,我将代码分解成一个文件,只调用mainloop()一次!