Milan,

I don't quite get the GetOpenFile{S<:String}(; filetypes::Vector{S}
=String[] syntax. I thought a function call needed () after it rather than 
curly braces. In any case here are my three functions (with an extra "2" in 
the file names so I could test them without worrying about duplicating 
existing functions. It isn't clear to me whether the GetSaveFile should 
remove the filetypes keyword. I'm only setup to test this on a Mac so I 
don't know how they work on Linux or Windows. One less than ideal issue is 
that on my computer the dialog isn't presented on top so I need to 
sometimes find it behind other windows. Something with the parent keyword 
might be needed, but I could only get that to work by creating a Tk 
TopLevel and even then it still was associated with the Terminal and not my 
browser or Juno. If you think the code as written is good enough to submit, 
I can try to do a pull request. 

Many thanks,

Eric

function GetOpenFile2(;filetypes::Vector=String[], initialdir::String="",
    initialfile::String="", multiple::Bool=false, title::String="")
  args = Dict()
  if length(filetypes) > 0 args["filetypes"] = filetypes end
  if length(initialdir) > 0 args["initialdir"] = initialdir end
  if length(initialfile) > 0 args["initialfile"] = initialfile end
  args["multiple"] = multiple
  if length(title) > 0 args["title"] = title end
  tcl("tk_getOpenFile", args)
end


function GetSaveFile2(;filetypes::Vector=String[], initialdir::String="",
                       initialfile::String="", title::String="")
  args = Dict()
  if length(filetypes) > 0 args["filetypes"] = filetypes end
  if length(initialdir) > 0 args["initialdir"] = initialdir end
  if length(initialfile) > 0 args["initialfile"] = initialfile end
  if length(title) > 0 args["title"] = title end
  tcl("tk_getSaveFile", args)
end


function ChooseDirectory2(;initialdir::String="",mustexist=false,title::
String="")
  args = Dict()
  if length(initialdir) > 0 args["initialdir"] = initialdir end
  if length(title) > 0 args["title"] = title end
  args["mustexist"] = mustexist
  tcl("tk_chooseDirectory", args)
end


On Saturday, February 28, 2015 at 9:05:57 AM UTC-6, Milan Bouchet-Valat 
wrote:
>
>  Le samedi 28 février 2015 à 06:58 -0800, Eric S a écrit : 
>
> Milan, 
>
>  
>
>  My problem was a semicolon instead of a comma in the call to 
> tcl("tk_getOpenFile", args). The function now seems to work. I can work up 
> versions for GetSaveFile and ChooseDirectory. Once they seem to work, what 
> is the process for suggesting they be included in the Tk package? 
>
> You can open a pull request against that package.
>
> Before that, I think you should change
> filetypes::Array=[]
> to
> filetypes::Vector=[]
> (or even 
> function GetOpenFile{S<:String}(; filetypes::Vector{S}=String[]
> so that it is clear that a vector of strings is expected)
>
> and change
> multiple=false
> to
> multiple::Bool=false
>
>
> Regards
>
>  function GetOpenFile2(; filetypes::Array=[], initialdir::String="",
>                        initialfile::String="", multiple=false, title::
> String="")
>   args = Dict()
>   if length(filetypes) > 0 args["filetypes"] = filetypes end
>   if length(initialdir) > 0 args["initialdir"] = initialdir end
>   if length(initialfile) > 0 args["initialfile"] = initialfile end
>   args["multiple"] = multiple
>   if length(title) > 0 args["title"] = title end
>   tcl("tk_getOpenFile", args)
> end 
>
>  
>
>  In [46]: 
>
>  
>  
>  GetOpenFile2(filetypes=["{Text files} {.txt}","{CSV files} {.csv}"],
> title="Select File",initialdir="/Users/ericshain/Documents/")
>
>  
>  
>  
>  Out[46]: 
>
>  "/Users/ericshain/Documents/MATLAB/Test 
> Data/CMV/11910_FP_PCR_3192010135222_MC.csv"
>
>
>
>  
> 

Reply via email to