7

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?

Henrik Schumacher
  • 106,770
  • 7
  • 179
  • 309
M.R.
  • 31,425
  • 8
  • 90
  • 281
  • 2
    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 https://mathematica.stackexchange.com/a/132065/38205 for more. – b3m2a1 Dec 08 '17 at 05:20
  • 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"] – b3m2a1 Dec 08 '17 at 05:22
  • 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 – Mike Honeychurch Dec 08 '17 at 06:07

1 Answers1

6

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.

b3m2a1
  • 46,870
  • 3
  • 92
  • 239