python - Tkinter 中的 'root.mainloop()' 导致 AttributeError
问题描述
在我的 python 代码中,该root.mainloop()
行导致错误:
AttributeError: '_tkinter.tkapp' object has no attribute 'mainLoop'
我在 Mac 上,我的代码是:
from tkinter import *
root = Tk()
myLabel1 = Label(root, text = 'My First GUI')
myLabel1.pack()
root.mainLoop()
解决方案
你应该更换:
root.mainLoop()
和
root.mainloop()
全部用小写字母。
推荐阅读
- php - Laravel Multilayered groupBy
- r - 考虑到r中数据框中的其他列条件,如何提取列的日期?
- android - 无法在 iOS 模拟器或物理设备上构建 Flutter 应用程序 - 虽然在 Android 上运行良好
- node.js - NextJS 自定义服务器在使用“npm run build”构建后出现 CORS 错误
- c# - 如何从 sqlite 数据库中检索浮点数到 C# 文本框
- python - 有没有办法在 html 网页中运行基本的 python 代码?
- kubernetes - Minio with helm install(分布式模式),如何在 kubernetes 中配置卷和 HA
- bootstrap-4 - 如何让 Bootstrap 4 Carousel 走出屏幕右侧?
- javascript - 如何计算自定义值的总和
- c++ - 如何设置 Fl_Text_Editor 的大小?