Version 45 of File selection dialog for Tile

Updated 2010-09-28 13:43:30 by msh

TR - This is a file selection dialog for Tile as a replacement for tk_getOpenFile, tk_getSaveFile, tk_chooseDirectory and even more! It was coded by Schelte Bron.

Commands

 ttk::getOpenFile
 ttk::getSaveFile
 ttk::chooseDirectory
 ttk::getAppendFile <- explain this one

sbron I added the getAppendFile version of the dialog because I needed a dialog that allows the user to select a log file. It is perfectly fine if the selected file did or did not exist. The other dialogs would either give a confusing warning for an existing file or not allow non-existing files at all.


Example (using xfce4 on Linux)

 package require tile
 tile::setTheme clam
 ttk::getOpenFile

http://tcl.typoscriptics.de/misc/fsdialog.gif


Get the files here: http://www.tclcode.com/fsdialog/fsdialog.zip

Installation instructions: Dump the files in the package (not the fsdialog directory) in a directory that is listed in $auto_path, or lappend the directory containing the files to auto_path.


TLu: 2006-12-30 In line 1594 should be '-mustexist' instead '-mustexists', because ttk::chooseDirectory has parameter '-mustexist'


MSH: 08/06/2006 Hi, This is a great widget I have included it into one of my programs and have a few comments: The standard dialogs have a '-multiple' option which I use to select multiple files for opening I have looked at the code but do not have the time to understand it to add this function do you have the intention of adding this ? Pressing ESCAPE on the standard dialogs will cancel the dialog. I downloaded the file at home for another project and discovered that the code had changed, is it possible to add a few comments to the code or even better a quick message here to signal any changes, so that any users can recover the latest. Thanks again I was preparing to develop something (almost certainly not as pretty) for my linux versions as the default dialogs don't look good on a tiled interface.


TR - There is a bug in the widget. When you resize it, you can no longer select a file. I will try to fix this if I get the time to dig into the code ...

MSH - Another bug is in the tk_chooseDirectory replacement which works great under linux but not under windows (at least 2000).

sbron - That's not a bug. It simply wasn't designed for windows. No compromises were made to support operating systems that don't have the proper capabilities needed for a timely display of the directory structure.

MG I admit I've not actually looked at these yet, but I wonder: is it worth using them on Windows? Since the aim of Tile is to provide a native look, and "real" native dialogs are already used on Windows, it seems a little strange to code up another version made to look exactly like the one we already use...

SEH 20060625 -- having good widgets like this is important and useful for every platform, because they can see files in Tcl virtual filesystems, while the native dialogs can't. For those working with vfs's, they're crucial.

MG Working with Tcl's vfs's is something I'd not thought of, and is a good point. Thanks :)

peterc 2008-08-28: On the flipside, outside the proprietory choosers provided by Windows & Mac OS X, is there a method to hide or disallow the browsing of particular locations or vfs filesystems? I'd much prefer it if X11 users weren't able to casually browse the directory structure of my starpack executibles ;-).


sbron 20070923 -- I have posted a new version that should address most of the issues raised above, and some others too:

  • Added -multiple option
  • Pressing ESC cancels the dialog
  • Using msgcat for the text strings (thanks to Mats Bengtsson, who also provided a Swedish translation catalog)
  • The -filetypes option no longer defaults to information from a previous call
  • Files can now also be selected after resizing
  • The selected file(s) remain highlighted after resizing or changing settings
  • Corrected typo in spelling of ttk::chooseDirectory -mustexist option

Adding the -multiple option was actually quite complicated and the code has become a bit of a mess as a result. It should probably be cleaned up and could also use more comments, but I have decided to publish it as is for now so people can start using it.


DKF: The Tk 8.5 file dialog (on Unix) uses Ttk widgets, and (tries to) style the standard Tk widgets that it uses to look like the current theme.


josevr 20080826 -- The array that stores the windows data is always the same: set dataName __ttk_filedialog. On the other hand, the window name depends on the parent: set w $data(-parent).$dataName. So when a new parent is used, a new window is created and cached for later usage. This creates a conflict when different dialogs are created with different parents: they will overwrite each other's dataName arrays!


sbron 20081228 -- I have updated the zip file mentioned above (twice today, as I found out soon after posting that ttk::messageBox is no longer needed). New in the latest version:

  • Allow the style command to be in either the global namespace or in ::ttk.
  • File name missing in warning for overwriting an existing file.
  • Add the -typevariable option introduced in 8.5 to the file selection dialogs.
  • Fix error when using the dialog with different parents.
  • File dialogs should use theme colors instead of their own hardcoded ones.
  • Fix error for some warning message dialogs.
  • Make sure the font isn't too big resulting in files not being visible.
  • Fix errors when opening the file selection dialog multiple times before selecting a file.

Martyn Smith 20090119 I have a user who is complaining that the scroll bars do not work properly. Example If you have long filenames, and you resize the filelist pane, as soon as you cover the last letters of the long filenames the scrollbar resizes in half (to scroll the canvas I presume) but the scroll bar cannot be moved because there is only one column !! Is this a simple fix ?

This seems to work properly in mixed mode and detailed mode, so the problem is in separate/files/folders short view mode only. I've started to look at the code and will post any more findings.

sbron 20090315 -- You didn't indicate how you would like to see this issue fixed, so I have adjusted the scrollbar display. I really prefer the files to always be aligned to the left side of the window and not allow free horizontal scrolling.

The changes in this version:

  • Correct scrollbar display when filenames are too long to fit in the window.
  • Fix error when navigating to a directory without having the proper permissions (new attempt).
  • Use nicer images if PNG support is available (Tk 8.6!)

Martyn Smith 20090324 Thanks for the fix. I did not have a preference for the fix, just that the scrollbar width and the filename width rest coherent.


sbron 20090703 -- The previous version breaks lassign on Tcl 8.5, so I fixed that. Also a German translation catalog has been added, thanks to Christian Rapp.


alexandra - 2010-08-13 16:55:36

Hello,

i have a question to Schelte Bron's fsdialog.tcl. It's a very great alternate for the old fileselectiondialog ! But how can i set the flag for select only directory ?

Or must i use the ttk::chooseDirectory ?

I think ttk::getOpenFile looks like better...

I hope for help..

my tcl projekt is a mp3 player and multimedia system for car pc's [L1 ]

thank you

alexandra

sbron 20100814 -- There is no option to select a directory with ttk::getOpenFile, that's what ttk::chooseDirectory is for. It's the same as the tk_getOpenFile and tk_chooseDirectory commands included in Tk.


Martyn Smith - 2010-09-28 15:30 Hello, I have started using the ttk::chooseDirectory and would like to be able to create a new directory and select it, the standard windows dialog allows a 'new directory', at the moment enter the new path at the top and in my code create the path if it is missing. Are there any plans to allow creating a new directory , I notice that it is possible in the open file dialogs.