我寫的Tkinter蟒蛇一個Hello World應用程序,但我recive下一條信息:「模塊」對象有沒有屬性「框架」Tkinter的,「模塊」對象有沒有屬性「框架」
import _tkinter as tk
這裏錯誤
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.pack()
self.createWidgets()
def createWidgets(self):
self.hi_there = tk.Button(self)
self.hi_there["text"] = "Hello World\n(click me)"
self.hi_there["command"] = self.say_hi
self.hi_there.pack(side="top")
self.QUIT = tk.Button(self, text="QUIT", fg="red",
command=root.destroy)
self.QUIT.pack(side="bottom")
def say_hi(self):
print("hi there, everyone!")
root = tk.Tk()
app = Application(master=root)
app.mainloop()
爲什麼會發生這種情況?
我很好奇。你是如何得出結論的:'將tt進口爲tk'是正確的?你有沒有讀過它? –