RE: Creating Palettes
- To: mathgroup at smc.vnet.net
- Subject: [mg86014] RE: [mg85967] Creating Palettes
- From: jose.luis.gomez at itesm.mx
- Date: Sat, 1 Mar 2008 04:49:07 -0500 (EST)
This code does the trick:
CreatePalette[{
PasteButton[a^2],
PasteButton[DisplayForm[RowBox[{"(", RowBox[{"1", "-", "a"}], ")"}]]],
PasteButton[(1 - a)^2]}];
Now, RowBox is really low-level programming (by low-level I mean not friendly
for end-users), so how can you know what is the correct Box structure for
an expression?
There is an easy way: in a Mathematica notebook write an expression, select
its corresponding cell, and selecet in the Mathematica menu called "Cell"
the option "Show Expression", from there you can "steal" the box structure
that you can use inside DisplayForm and inside PasteButton.
Notice that, in this example, if you give a value to the variable a before
creating the palette, then when you create the palette the button with a^2
will not show a^2, it will show the result of the calculation, while the
button with RowBox will show (1-a), exactly the same if "a" has or has not
a value.
Hope it helps
Jose
http://homepage.cem.itesm.mx/lgomez/
Mexico