Snippets Palettes - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Information : Updates : Maple 16 : Snippets Palettes

Snippets Palettes in Maple 16

 

Maple 16 introduces customizable Snippets Palettes.  These are palettes, just like the standard palettes you can display on the left and right sides of your Maple window, but you can add and remove them at will and populate them with buttons which implement the functionality you need.  

 

Once created, you can use the palette manager, available from the View menu, to manage the placement and display of your palette, just as you would any other palette.

 

Snippets palettes are populated with buttons which you can paint with your own images.  You associate each such button with a task, which can be a standard task from the Task Browser, available from the Tools menu, or a task of your own design.

 

 

 

The commands you use to create and manage a snippets palette are part of the DocumentTools package.

 

The first step is to choose the tasks that you want to have available from your palette.  You can either choose a task from the Task Browser or create your own.  There are 3 methods you can use to create your own tasks:

 

1. 

Make a Maple worksheet which has exactly your task contents in it.  Then from the Tools > Help Database submenu choose Save as Task ... .  Follow the instructions in the resulting dialog.

2. 

Highlight a section of a worksheet, right-click to display the context menu and choose Create Task.

3. 

Obtain the XML for a worksheet which defines your task, for example, using the XMLTools and FileTools packages and then use DocumentTools[ CreateTask ] to convert this to a task.  This method is the most complicated, but has the advantage that it can be programmed.

 

In our example, we will use the second method.

 

Using your mouse, select the entire (blue) box to the right, then, with the mouse in the selected area, right-click and choose Create Task.  In the dialog which appears, name the task My Task and click Ok.

withDocumentTools

AddIcon,AddPalette,AddPaletteEntry,CreateTask,Do,GetDocumentProperty,GetProperty,InsertContent,InsertTask,RemovePalette,RemovePaletteEntry,RemoveTask,Retrieve,RunWorksheet,SetDocumentProperty,SetProperty

(1)

 

Define the task.  Our example will take a function and some options and draw the corresponding graph.

f =

Plot from  to

Use the discont option

Next, we need an icon for our palette task.  For this, we will just use one of the sample images which is distributed with Maple.  We'll need to resize it so that it is about the same size as icons in other Maple palettes, which we can do using the ImageTools package.

 

The AddIcon command in the DocumentTools package takes as input the name of a file containing the image you want to use.  Execute the code on the right to create our icon.

mytaskiconImageToolsScaleImageToolsRead catkerneloptsdatadir, /images/tree.jpg , 1..32, 1..32:

iconfile  catFileToolsTemporaryDirectory,kerneloptsdirsep, FileTools:-TemporaryFilename:

ImageToolsWriteiconfile, mytaskicon, format=JPEG:

DocumentToolsAddIconMy Icon, path = iconfile;

Finally, we create our palette and add the task with its icon.

 

The AddPalette command in the DocumentTools package takes an option called store, with value true or false.  If this option is not provided or is given as store=false, then the palette that is created will live only for the duration of your current Maple session.  If you want your palette to be available to you in future Maple sessions, use store or store=true for this option.

 

After executing the code to the right, you should see your brand new snippets palette at the top of the palette dock to the left of this work area (you may need to click the small right-arrow ( ) button at the top of this window to see the palettes).

 

To test it out, open a new document (File > New) and press the button in the My Palette palette.

DocumentToolsAddPaletteMy Palette:

DocumentToolsAddPaletteEntryMy Task, palette=My Palette, icon=My Icon: