当运行我的程序进行函数调用时
self.getFileButton = Button(self,
text = "...",
command =
tkFileDialog.askopenfilename(mode="r+b", **self.file_opt))
我明白错误
File "C:/Documents and Settings/l/My Documents/Python/csv_GUI.py", line 33, in create_widgets
tkFileDialog.askopenfilename(mode="r+b", **self.file_opt))
AttributeError:selectFile实例没有“file\u opt”属性
最佳答案
您是否在您的file_opt
方法或其他地方定义了__init__
成员?
?如果不是,那么mgilson的解决方案是正确的。但在其他方面,就简单多了。
如果你在任何地方都没有一个getFileButton
成员,那就更简单了:不要试图通过那些不存在的东西。