我看了一下,但找不到我的错误的答案。代码如下:
import tkinter as tk
root=tk.Tk()
class Page(tk.Frame):
'''Enables switching between pages of a window.'''
def __init__(self):
self.widgets={}
self.grid(column=0,row=0)
page=Page()
tk.mainloop()
错误如下:
Traceback (most recent call last):
File "C:\Documents and Settings\Desktop\Python Scripts\Tkinter.py", line 11, in <module>
page=Page()
File "C:\Documents and Settings\Desktop\Python Scripts\Tkinter.py", line , in __init__
self.grid(column=0,row=0)
File "C:\Python34\lib\tkinter\__init__.py", line 2055, in grid_configure
self.tk.call(
AttributeError: 'Page' object has no attribute 'tk'
我对tkinter还很陌生,这个错误让我难堪。我非常感谢你的帮助,谢谢!
您的
Page
init方法应该调用Frame
的init。相关问题 更多 >
编程相关推荐