1
我正在使用tkinter devoloping一个桌面应用程序。设置字体引发异常。tkinter字体中没有属性“call”错误
tmp.py
def main(root):
frame = Frame(root.master)
font = Font(size=25 , weight="bold")
label = Label(frame , font=font , text="tuna fish")
label.pack()
frame.pack()
这是驱动器程序main.py main.py
if __name__ == "__main__":
root = start.baseApp()
root.Menu_Customer.add_command(label="New customer", command=lambda: tmp.main(root=root))
root.master.mainloop()
baseApp
我已创建根窗口并带有名称的菜单栏客户并添加菜单项新客户main.py
。
我得到在tmp.py
异常说
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib64/python3.5/tkinter/__init__.py", line 1559, in __call__
return self.func(*args)
File "main.py", line 10, in <lambda>
root.Menu_Customer.add_command(label="New customer", command=lambda: tmp.main(root=root))
File "/home/engle/Documents/Project/CleanMaster/tmp.py", line 6, in main
font = Font(size=25 , weight="bold")
File "/usr/lib64/python3.5/tkinter/font.py", line 93, in __init__
tk.call("font", "create", self.name, *font)
AttributeError: 'NoneType' object has no attribute 'call'
什么错呢?
您是否包含此行:'import tmp'? –
当然是男人。我输入了。 – deepak
我不能运行你的代码,因此不能排除它的故障,请检查这一点,并相应地修改https://stackoverflow.com/help/mcve –