【发布时间】:2016-12-07 08:09:31
【问题描述】:
嗯,我想添加菜单栏,但是出了点问题。
上面写着:AttributeError: 'NoneType' object has no attribute 'config'
我的代码:
from tkinter import *
class ApplicationWindow(Tk):
def __init__(self, master=None):
Tk.__init__(self, master)
self.master = master
self.geometry('800x400')
self.f_app = Frame(self).pack()
menubar = Menu(self.master)
self.master.config(menu=menubar)
fileMenu = Menu(menubar)
fileMenu.add_command(label="Exit", command=self.onExit)
menubar.add_cascade(label="File", menu=fileMenu)
self.b_log = Button(self, width=10, text="Войти", command=self.func).pack()
def onExit(self):
self.quit()
def func(self):
print("hello")
def main():
# root = tk
app = ApplicationWindow()
app.mainloop()
if __name__ == '__main__':
main()
【问题讨论】: