When running my program that makes the function call
self.getFileButton = Button(self,
text = "...",
command =
tkFileDialog.askopenfilename(mode="r+b", **self.file_opt))
I get the error
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 instance has no attribute ‘file_opt’
Do you actually have a
file_optmember defined in, e.g., your__init__method, or elsewhere?If the problem is that you are defining one, but not until after you’ve done the
getFileButton, can you just rearrange the order? If not, mgilson’s solution is the right one. But otherwise, it’s much simpler.And if you don’t have a
file_optmember anywhere, it’s even simpler: Don’t try to pass something that doesn’t exist.