Message Boards Message Boards

0
|
8039 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Palette from Mathematica 9 Does Not Work on Mathematica 10

Posted 10 years ago

Looks like first posting was deleted.

I have a Mathematica Palette that works on Mathematica 9 but not on Mathematica 10. The palette turns text into a hyperlink to a local file or folder on my computer - again it works on M-9 but not on M-10. See code below and resulting output on M-10 where the text does not turn into a link but rather raw Mathematica code.

Does anyone know if I need to de-install the M-9 palette and re-install on M-10? If yes, how do I do this?

Here is the output on M-10

RawData[ButtonBox["let's make a link", BaseStyle -> "Hyperlink", ButtonData -> "D:\\userdata\\qa4078\\Desktop\\someText.txt", ButtonFunction -> (SystemOpen["D:\\userdata\\qa4078\\Desktop\\someText.txt"]& ), Evaluator -> Automatic, Method -> "Preemptive"]]

Here is the palette code

CreatePalette[
DynamicModule[{nb},
Button["Insert File/Folder Hyperlink",
nb=InputNotebook[];
CreateDialog[
DynamicModule[{file="",setterSpec="Open"},
Column@
{Row@
{"Hyperlink to ",
SetterBar[Dynamic@setterSpec,
{"Open"->"File","Directory"->"Folder"}
]},
Row@
{InputField[Dynamic@file,String],
Dynamic@FileNameSetter[Dynamic@file,setterSpec]},
Row@
{DefaultButton[
NotebookWrite[nb,
RawData@
ButtonBox[NotebookRead@nb,
BaseStyle->"Hyperlink",
ButtonData->file,
ButtonFunction->With[{f=file},SystemOpen@f&],
Evaluator->Automatic,
Method->"Preemptive"
]
];
DialogReturn[]
],
CancelButton[]}},
InheritScope->True
],
WindowTitle->"Inserting in \""<>CurrentValue[nb,"NotebookFileName"]<>"\""
]
]
],
WindowTitle->"File/Folder Hyperlink",
Saveable->False
];

Here are the images of the palette button and palette browser to select the file or folder to link

Palette Button enter image description here

POSTED BY: Bob Stephens
2 Replies
Posted 10 years ago

Thanks, your modifications to the code do work for creating a file or folder link - however, each time the palette is first selected from the palette menu, the palette notebook needs to be evaluated to bring up the button view even after this version of the palette is installed. So, I need to debug this next.

POSTED BY: Bob Stephens

I found that the palette worked the very first time I tried, provided I first selected some text (in Text style; I didn't try other styles) and then clicked the palette button, but not if I did not select anything beforehand. But this was after evaluating the code in v10 and directly using the palette notebook created; have you tested this? However, when I tried this again, I found the same issue that you did and I was not able to recreate a successful outcome. That I found odd. So I tried a few things, including replacing the RawData[...] with Cell[RawData[...]] and removing the Saveable option completely. That seemed to work (see attached file) but I did not manage to save the palette generated.

There is a separate procedure to install palettes, assuming you are successful in re-creating a palette that works (you could try simply replacing the code of the palette though a safer way would be to install a fresh palette, perhaps more seasoned Mathematica users might be sure of the best method). There could be an issue with saving the palette created with your code as you explicitly prevent saving of the palette using the un-integrated option Saveable.

Attachments:
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract