嘿,伙计们,我只是想创建一个简单的按钮gui(绝对n00b) 但我似乎能找出我的代码有什么问题:
``__author__ = 'Isaac'
from Tkinter import *
class Application(Frame):
""" My smart board application"""
def __init__(self, master):
Frame.__init__(self, master)
self.grid()
self.create_widgets()
def create_widgets(self):
#Button1
self.button1 = Button(self, text = "Calandar")
self.button1.grid()
#button2
self.button2 = Button(self)
self.button2.grid()
self.button.configure(text = "Weather")
root = Tk()
root.title("Smartboard")
root.geometry("500x400")
app = Application(root)
root.mainloop()
我得到的错误是:
C:\Python27\python.exe "C:/Users/Isaac/Desktop/Useful python/Clanadar/GUIOOP.py"
Traceback (most recent call last):
File "C:/Users/Isaac/Desktop/Useful python/Clanadar/GUIOOP.py", line 25, in <module>
app = Application(root)
File "C:/Users/Isaac/Desktop/Useful python/Clanadar/GUIOOP.py", line 11, in __init__
self.create_widgets()
File "C:/Users/Isaac/Desktop/Useful python/Clanadar/GUIOOP.py", line 20, in create_widgets
self.button.configure(text = "Weather")
AttributeError: Application instance has no attribute 'button'
Process finished with exit code 1
谢谢你的帮助
在您的“#button2”注释下;下面3行,您使用
但是,没有称为“button”的变量。我想你是想说:
相关问题 更多 >
编程相关推荐