大佬教程收集整理的这篇文章主要介绍了在 Tkinter 中使用 Button 对象时出现错误,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
运行此代码时:
import tkinter as tk
class MyApplication(tk.Tk):
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)
self.title('ProgrAMMa')
self.geometry('500x400')
self.button = tk.button(self,text='Execute',command=self.fun)
self.button.grID(row=0,column=4,stick=tk.W)
def fun(self):
print('Hello')
app = MyApplication()
app.mainloop()
我收到以下错误:
TraceBACk (most recent call last): file "C:/Users/Andrea/Desktop/hfhfhg.py",line 17,in <module>
app = MyApplication() file "C:/Users/Andrea/Desktop/hfhfhg.py",line 10,in __init__
self.button = tk.button(self,command=self.fun) file "C:\WPy64-3910\python-3.9.1.amd64\lib\tkinter\__init__.py",line 2346,in __getattr__
return getattr(self.tk,attr) AttributeError: '_tkinter.tkapp' object has no attribute 'fun'
我知道代码对于 GUI 来说不是最佳的,但我想了解 Tkinter 如何在不使用框架对象的情况下工作。请问你能帮我吗?
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的在 Tkinter 中使用 Button 对象时出现错误全部内容,希望文章能够帮你解决在 Tkinter 中使用 Button 对象时出现错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。