嘿伙计们我试图用tkinter
创建一个简单的程序,现在我想要它做的就是打开一个空白的GUI。目前我收到此错误:
Traceback (most recent call last):
File "C:/Users/User/Desktop/firstTkinter.py", line 3, in <module>
class simpleapp_tk(tkinter.tk):
AttributeError: 'module' object has no attribute 'tk'
这就是我写的代码:
import tkinter
class simpleapp_tk(tkinter.tk):
def __init__(self,parent):
tkinter.tk.__init__(self,parent)
self.parent=parent
self.initialize()
def initialize(self):
'best to have a portion of code that creates all gui elements. This is the point of initialize()'
pass
if __name__=='__main__':
app=simpleapp_tk(None)
app.title('my application')
app.mainloop()
答案 0 :(得分:2)
它是Tk()
,而不是tk()
。