python-3.x - “AttributeError: '_tkinter.tkapp' 对象没有属性 '__name__'” 在使用 '.after_idle' 时
问题描述
我.after_idle
用来确保我的 tkinter 程序在循环中不会崩溃。
但是每次我按下start
(tkinter.Button()) 按钮时,都会发生这种情况:
Exception in Tkinter callback
Traceback (most recent call last):
File ************************************************************, line 1883, in __call__
return self.func(*args)
File ************************************************************, line 78, in panel
win.after_idle(win, panel)
File ************************************************************, line 820, in after_idle
return self.after('idle', func, *args)
File ************************************************************, line 810, in after
callit.__name__ = func.__name__
File ************************************************************, line 2345, in __getattr__
return getattr(self.tk, attr)
AttributeError: '_tkinter.tkapp' object has no attribute '__name__'
我怎样才能解决这个问题?是什么原因造成的?帮助回答:
这是我的代码:
import tkinter
import os
import time
#control rod percentages
cr1 = 100
p = '%'
#grid pieces
c1 = 'CTRL ROD 01 '
ins = ' INSERTED'
grid1 = ' _________________________ '
grid2 = '|'
grid3 = '|_________________________|'
def panel():
print(grid1)
print(grid3)
win.after_idle(panel)
os.system('cls')
win = tkinter.Tk(className=' N.M.S. ')
w = tkinter.Button(win, activeforeground="black", activebackground="red", bg="grey", fg="black", command=panel, text="START", height=1, width=10)
w.pack()
win.mainloop()
-------------------------------------------------- - -[笔记] - - - - - - - - - - - - - - - - - - - - - - ----------------------
此代码不完整。它处于建设和测试阶段。我刚刚遇到了这个问题,我真的被它难住了。
PS:我使用的是 python 3.8.0。这有什么改变吗?
解决方案
推荐阅读
- python - 从 txt 输出中解析多行
- node.js - 如何将 app.use 分离到不同的文件
- javascript - JavaScript 算法:有没有更好的方法从排序数组中获取异常,其中任意两个连续数组之间的差为 1
- math - 三角形相交
- python-3.x - 从另一个函数调用python函数时,如何让调用函数知道错误?
- php - 如何在特定的 Wordpress 用户下添加产品?
- python-3.x - 使用rosbag和dynamixel在ros中获取位置和移动机器人关节
- javascript - Mac m1 节点 ffi-napi 抛出错误“找不到合适的图像”。和“ mach-o,但架构错误”
- python-3.x - 如何正确重新采样到 5 分钟
- extjs - 为什么 ExtJS 排序器函数必须返回 -1/0/1