1

I have an application that I am attempting to build on Mac OS X that is primarily python and uses tk as its gui.

It appeared to build okay and I can see the GUI, but when I click the browse button, which invokes tkFileDialog.askopenfilename(**options), I am not getting an option to select the file type and therefore cannot select the file I want to open (that appears to be what is happening.)

I'm sure their is an obvious explanation for this, but I am a complete newb to Mac and my Google-fu was just not up to solving this problem.

Here is an example of the options as they are currently set:

file_opt = options =  {}
options['filetypes'] = [('gzipped SOFT', '.soft.gz'), ('SOFT', '.soft'),('Comma Separated', '.csv')]
options['parent'] = self
options['initialdir'] = 'data'
options['title'] = "AHREA - Select data file."
response = tkFileDialog.askopenfilename(**options)

The code works fine on Windows and Linux, so I must just not get what I am doing on Mac.

Thanks.

1 Answer 1

1

Which extension do you want to open?

Try

options['filetypes'] = [('all files', '.*'), ('text files', '.txt')]

Or if you completely remove this line Tk should (as per the docs) list all available files. The same happens when the file type selection is not supported on your Tk / platform combination.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.