Message Boards Message Boards

5 Replies
0 Total Likes
View groups...
Share this post:

Am I using the GUIKit package FileDialog Widgit properly?

Posted 11 years ago
In a Mathematica notebook, I execute the following lines,
What looks like a standard File Dialog window appears.  Using the dialog, I select a file and then click the "Open" button and nothing happens.  The dialog remains on the screen and there is no indication of any activity on the notebook.  Normally when I use a file dialog in Java or a dot net language the dialog disappears when I click the open button and the file path/name string are placed in a variable and I use that string to open the file. 

I looked at the documentation on FileDialog and it is anything but clear which doesn't surprise me too much. 

So, does anyone know how to use the FileDialog in Mathemetica?

5 Replies
Which version of Mathematica are you trying this with, and which operating system and level?
POSTED BY: Bruce Miller
Posted 11 years ago
Thank you for the help. 

I'm not too keen on the first response.  I really wanted a ready made file dialog solution.  Call me lazy. emoticon

I like the second response.  I tried it and it worked just fine. 

I wonder why Wolfram went to all the trouble to make that Widget "FileDialog" that doesn't work and in fact, does absolutely nothing?
One cannot state that it is not working, because there is an example in the Help GUIKit/tutorial/TextImportWizard if you call it it opens a file dialog

and in the Code section above in the manual you see where the code comes from: it is in directory (drive letter depends on local installation)
S:\Program Files\Wolfram Research\Mathematica\9.0.1\AddOns\Packages\GUIKit\GUI\Wolfram\Example

and there are files TextImportWizard.m and TextImportWizardScriptCode.m and in the latter one there is BrowseFilename[] which works and uses a Widget["FileDialog", ...] and can serve as a starting point.
POSTED BY: Udo Krause
In[23]:= SystemDialogInput["FileOpen"]

Out[23]= "N:\\Udo\\Abt_N\\test\\bertGraph.jpeg"

simple and direct; the interactive examples in Mma 9.0.1 Help GUIKit/ref/widget/FileDialog need some effort to be intelligible, I've to confess.
POSTED BY: Udo Krause
Here is some earlier code

assuming that "test" is a direct subdirectory of NotebookDirectory[] and that there are 2 files bertGraph*.jpep and morleyS18*.jpeg in subdirectory test. If you run the following  cell and click in the appearing window
  Widget["Panel", {
     "Button", {"text" -> "bert",
      BindEvent["action", Script[showB[1]]]}, Name -> "button1"],
     "Button", {"text" -> "morley",
      BindEvent["action", Script[showB[2]]]}, Name -> "button2"],
    Widget["ImageLabel", Name -> "Bilderleiste"],
   Script[showB[n_Integer] :=
     SetPropertyValue[{"Bilderleiste", "data"}, Block[{files, ims},
       SetDirectory[NotebookDirectory[] <> "\\test"];
       files = If[Mod[n, 2] == 1,
       ims = Import /@ files;
       (* Print["Es war Schalter: ", n]; *)
       ExportString[GraphicsRow[ims], "JPEG"]
   }, Name -> "myPanel"]]
on "bert" or on "morley", it opens the corresponding jpeg File in the window as shown here

using this you should be able to use FileDialog[] too.
POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract