Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 &引用;AttributeError:类框架没有属性';显示U帧'&引用; 这是我的代码,我试图在其中链接两个页面_Python 2.7_Tkinter - Fatal编程技术网

Python 2.7 &引用;AttributeError:类框架没有属性';显示U帧'&引用; 这是我的代码,我试图在其中链接两个页面

Python 2.7 &引用;AttributeError:类框架没有属性';显示U帧'&引用; 这是我的代码,我试图在其中链接两个页面,python-2.7,tkinter,Python 2.7,Tkinter,但在这里我得到了这个错误信息: AttributeError: class Frame has no attribute 'show_frame' how to remove this error 首先,您不能像在command=lambda:controller.show_frame(…)中那样调用lambda 假设您进行了我在当前程序中没有看到的必要导入,只需将这两条语句(在代码的两行中)替换为:command=controller.show_frame(…) 请阅读 其次,您的代码在这

但在这里我得到了这个错误信息:

AttributeError: class Frame has no attribute 'show_frame'
how to remove this error 

首先,您不能像在
command=lambda:controller.show_frame(…)
中那样调用lambda

假设您进行了我在当前程序中没有看到的必要导入,只需将这两条语句(在代码的两行中)替换为:
command=controller.show_frame(…)

请阅读

其次,您的代码在这一行附近包含另一个错误:

if name == 'main':
   main()
将其更改为:

if __name__ == '__main__': 
   main() 
修复您的错误后,我成功运行了您的程序:


另外,你可能会对这篇文章感兴趣:

我已经试过你的代码,它正在工作
if __name__ == '__main__': 
   main()