Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(<unknown>:2678): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
Yes, something like the EasyDialogs Python package would be great.
GetOpenFile(initialdir="/tmp")
You did a good job on the docs, want to put this together for the function definitions?
julia> z=tcl("tk_getOpenFile", filetypes=["Text files {.txt}"])
If I leave out the filetypes, I can select any files. As for the implementation, you can pass in as few or as many keyword arguments in a Dict. I think just allowing the user to set up the Dict is easier than exposing each of the keywords separately in the function call just because there are so many of them. The following works for instance:
julia> kwarg = Dict();
julia> kwarg["title"]="Pick a file";
julia> kwarg["multiple"]=true;
julia> z=tcl("tk_getOpenFile", kwarg)
Eric
> ...
> ...
...
function GetOpenFile2(; filetypes::Array=[], initialdir::String="",
initialfile::String="", multiple::Bool=[], title::String="")
args = Dict()
if length(filetypes) > 0 args["filetypes"] = filetypes end
if length(initialdir) > 0 args["initialdir"] = initialdir end
if length(initialfile) > 0 arg["initialfile"] = initialfile end
if length(multiple) > 0 args["multiple"] = multiple end
if length(title) > 0 args["title"] = title end
tcl("tk_getOpenFile"; args)
end
...
Le vendredi 27 février 2015 à 15:48 -0800, Eric S a écrit :
Well, I'm trying but not getting too far. I tried the code as suggested by Milan but got errors. I then tried to mimic what I say in the Messagebox code in the Tk package. This is what I have so far:
function GetOpenFile2(; filetypes::Array=[], initialdir::String="", initialfile::String="", multiple::Bool=[], title::String="") args = Dict() if length(filetypes) > 0 args["filetypes"] = filetypes end if length(initialdir) > 0 args["initialdir"] = initialdir end if length(initialfile) > 0 arg["initialfile"] = initialfile end if length(multiple) > 0 args["multiple"] = multiple end if length(title) > 0 args["title"] = title end tcl("tk_getOpenFile"; args) end
I coded this in Juno but got an error message that keyword args needs a default value. Not sure why since it doesn't have one in Messagebox. Not sure how to proceed.
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
"/Users/ericshain/Documents/MATLAB/Test Data/CMV/11910_FP_PCR_3192010135222_MC.csv"
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?
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
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.