Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么python会显示;TCL错误:can';t调用;地点;命令:应用程序已被销毁";在下面的代码中_Python_Tkinter - Fatal编程技术网

为什么python会显示;TCL错误:can';t调用;地点;命令:应用程序已被销毁";在下面的代码中

为什么python会显示;TCL错误:can';t调用;地点;命令:应用程序已被销毁";在下面的代码中,python,tkinter,Python,Tkinter,我正在尝试建立一个论坛,一旦你点击确认,它就会自动关闭。另外,我使用spyder(以防万一),我刚刚开始tkinter的概念。我试图在谷歌上找到答案,但没有那么成功 您在这一行中调用“close_window()”:“confirm=tk.Button(text=“confirm”,command=close_window())”请发布完整的错误消息这是否回答了您的问题?您应该像下面这样传递函数close\u window()“confirm=tk.Button(text=“confirm”,c

我正在尝试建立一个论坛,一旦你点击确认,它就会自动关闭。另外,我使用spyder(以防万一),我刚刚开始tkinter的概念。我试图在谷歌上找到答案,但没有那么成功

您在这一行中调用“close_window()”:“confirm=tk.Button(text=“confirm”,command=close_window())”

请发布完整的错误消息这是否回答了您的问题?您应该像下面这样传递函数close\u window()“confirm=tk.Button(text=“confirm”,command=close\u window)”,您可能会尝试破坏该窗口两次。您可以做的是尝试销毁它,并在它已被销毁时传递try:window.destroy()除了:pass
import tkinter as tk

def close_window():
    print ("")
    window.destroy()

window = tk.Tk()
window.geometry("750x350")

username = tk.Label(window, text = "Enter Username")

password = tk.Label(window, text = "Enter Password")

input1 = tk.Entry(window)

input2 = tk.Entry(window, show = "*")

confirm = tk.Button(text="Confirm", command = close_window()) 

input1.place(x=400, y=35)

input2.place(x=400, y=65)

username.place(x=150, y=35)

password.place(x=150, y=65)

confirm.place(x=400, y=100)

confirm.pack()

window.mainloop()