7
$\begingroup$

I have some thumbnails that I want to use inside my package, which need to be loaded with FEPrivate`FrontEndResource. AFAIK those assets have to be placed in .tr files in this exact directory (on macOS):

/Applications/Mathematica.app/Contents/SystemFiles/FrontEnd/TextResources

Now of course one could manually copy them over on installation, but what if I'm using PacletInstall? What are the best practices here for distribution?

$\endgroup$
3
  • 2
    $\begingroup$ They should be placed in pacletDirPath/FrontEnd/TextResources/resource.tr. These get added to the resource path automatically by the PacletManager if FrontEnd is set in the extensions. See mathematica.stackexchange.com/a/132065/38205 for more. $\endgroup$
    – b3m2a1
    Commented Dec 8, 2017 at 5:20
  • $\begingroup$ I believe you have my Qwant service connection installed. You can see how I handled the "SystemResources" equivalent by looking at that via: SystemOpen@PacletFind["*_Qwant"][[1]]["Location"] $\endgroup$
    – b3m2a1
    Commented Dec 8, 2017 at 5:22
  • $\begingroup$ You can also add them to ~Applications/Your application/FrontEnd/TextResources which is what I do for modifying menus and contextual menus when my application is running $\endgroup$ Commented Dec 8, 2017 at 6:07

1 Answer 1

6
$\begingroup$

So I tossed this in a comment, but it deserves some elaboration.

The appropriate place is the "FrontEnd/TextResources" subdirectory in your paclet.

You can see how WRI does this by looking at the CloudObject paclet:

PacletFind["CloudObject"][[1]]["Location"] // SystemOpen

You then need to add

{"FrontEnd", Prepend -> True}

As an extension in your PacletInfo.m

Szabolcs has more info here

Finally, all the paclet manager does is add the text resource directories to:

CurrentValue[$FrontEndSession, {PrivatePaths, "TextResources"}]

And in fact you can see this is how the CloudObject system adds its resources:

CurrentValue[$FrontEndSession, {PrivatePaths, "TextResources"}][[1]]

FrontEnd`FileName[{$UserBaseDirectory, "Paclets", "Repository", 
  "CloudObject-11.2.1398", "FrontEnd", "TextResources"}, 
 "PacletManager" -> True, "Prepend" -> True]

Thus any arbitrary directory you want to use can be added like that, which gives you a way to dynamically set a directory at paclet loading.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.