Menu

#1585 Tk_getOpenFile in Aqua requires that initialfile exists

obsolete: 8.4.4
closed-invalid
5
2004-03-30
2003-10-23
Anonymous
No

Tcl/Tk 8.4.4 Aqua for MacOS X (rel. 10.2.8) requires
that a file specified as initial file exist.

Example:

set FileName [tk_getOpenFile -initialfile example.txt]

If the file example does not exists, tk_getOpenFile aborts
with the message

bad initialfile "example.txt" file does not exist.

On other platforms incl. fink the initial file name is
listed by the widget. The Aqua widget has no room
for this and a suitable behaviour could be just to
ignore the initialfile name if the file does not exist.

Furthermore, file types are ignored. Thus even

set FileName [tk_getOpenFile -filetypes {
{{Text Files} {.txt}}
}]

is specified, all files in the directory are listed.

Peter Balling
pballing@asc-consult.com

Discussion

  • Jim Ingham

    Jim Ingham - 2003-10-23

    Logged In: YES
    user_id=169107

    Sorry, but I don't see the point of listing a non-existant file name
    in an Open dialog. There is no place to list this in the Aqua widget
    because the Nav Services dialog for opening files doesn't have a
    place to list it. But again, what would be the point? If it doesn't
    exist, you aren't going to be able to open it anyway...

    The part about file types is a separate bug. Don't put two bugs in
    one report, it makes tracking bugs harder. But you don't need to
    report the filetypes failure, there is a bug about this already. The
    NavServices started passing FSRef's to the filter proc rather than
    FSSpec's in 10.2, and I need to rev the filter proc to handle both
    structures...

     
  • Jim Ingham

    Jim Ingham - 2003-10-23
    • status: open --> open-invalid
     
  • Jim Ingham

    Jim Ingham - 2003-10-24
    • status: open-invalid --> closed-invalid
     
  • Peter Balling

    Peter Balling - 2003-10-29

    Logged In: YES
    user_id=893234

    The reason for having a non-existing file in the open dialog may
    be to have it act as either a template to change interactively or
    start as a pattern to start a search.

    The Tcl/Tk man pages allow -initialfile both for Tk_getOpenFile
    and Tk_getSaveFile and do not state that the file must exist. This
    is allowed on other platforms. It should be allow for Aqua as well
    for compatibility and simply ignored, not crashing the open dialog.

    pballing@asc-consult.com

     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902

    The general model is that [tk_getOpenFile] is for getting
    the name of an existing file to open, and [tk_getSaveFile]
    is for getting the name of a file (possibly existing,
    possibly not) to save the current program state (in some
    sense, hopefully obvious!) as. Opening something based on a
    template is a different way of working that lies outside the
    scope of those commands (and that's expected to be the case
    on all platforms.)

     
  • Peter Balling

    Peter Balling - 2003-10-29

    Logged In: YES
    user_id=893234

    But the open dialog should not crash. I had
    to rewrite my application setting -initalfile names
    for non existing files to "" for Tk_getOpenFile in
    Aqua. This was complicated
    by the fact that tcl_platform does not seem to
    distinguish between Aqua Tcl/Tk and Fink Tcl/Tk
    where the problem does not exist.

     
  • Vince Darley

    Vince Darley - 2003-10-29

    Logged In: YES
    user_id=32170

    Obviously it shouldn't crash, but according to your original
    report, it doesn't crash -- it just throws a nice helpful
    Tcl error message.

    To distinguish between Fink and Aqua, use 'tk windowingsystem'.

     
  • Peter Balling

    Peter Balling - 2003-10-29

    Logged In: YES
    user_id=893234

    Thanks for the info on 'tk windowing system'.

    I wrote that that tk_getOpenFile aborted (and it
    left me being unable to open any file before the'application was
    changed. It did not crash Tcl/Tk or the application).

     
  • Don Porter

    Don Porter - 2004-03-30
    • labels: 394429 --> 37. [tk_get*File]