enabling multiple file types

Posted by dbrien on 2016-07-21 09:45

Using the latest versions of ActiveState TCL ( or with Mac OS 10.10, the selection of different file types for selecting a file is not enabled. Here is a snippet of code:

if demfile == None:
self.file_opt = options = {}
options['filetypes'] = [('All files', '*'),('ASCII files', '*.asc')]
options['initialdir'] = scoops.DefaultDir
fname = tkFileDialog.Open(**self.file_opt).show()

fname = demfile

When opening a file in older versions of TCL, the Open window created would have a dropdown menu on the bottom with the option to select different file types. The dropdown choices are titled 'Enable'. In the more recent versions of TCL, this dropdown does not appear and the user is only allowed to select 'ASCII files'.
Any suggestions?

ActiveState Staff
Tue, 2016-07-26 11:48

A number of commands have changed in the Tkinter API to support Tcl/Tk 8.5

tkFileDialog is one of them:

New syntax should look more like this example:
from tkinter import filedialog
filename = filedialog.askopenfilename()
filename = filedialog.asksaveasfilename()
dirname = filedialog.askdirectory()

From Tkdocs
Standard Dialogs | Selecting Files and Directories.

Also, Tkinter will not use any Tcl 8.6 yet. It can only use a correctly installed 8.5. Tcl versions are defined according to the standards set by Python.org for the specific release when the module is compiled and can't be re-set.