python - 为什么python在以下代码中显示“TclError:无法调用“place”命令:应用程序已被破坏”
问题描述
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()
我正在尝试创建一个在您单击确认后自行关闭的论坛。另外,我使用 spyder(以防万一),我刚刚开始了 tkinter 的概念。我试图在谷歌上找到答案,但没有那么成功。
解决方案
您在这一行中调用“close_window()”:“confirm = tk.Button(text="Confirm", command = close_window())”
推荐阅读
- regex - 一定位数的正则表达式
- python - 如何从python子进程的输出中去除和删除特殊字符
- javascript - Firebase - 识别从 iOS 应用到网页的用户身份验证
- python - 我想不断地画一条可以用按键转动的线
- hyperlink - 断开指向 Excel for PowerPoint 图表的链接
- sql - SQL:为其他列中的每个唯一实体提取与列最大值有关的行段
- javascript - 无法在 Mac OS 中安装 Maven
- separation-of-concerns - 在更高层编写接口是否被认为是一种好习惯?
- python - scrapy内部链接+管道和mongodb集合关系
- spring - JHipster Spring Boot 使用的 ComponentFind 设置的包名在哪里?