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 exampl开发者_运维问答e 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.
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.
精彩评论