MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Creating Palettes

This code does the trick:

   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

Hope it helps


-----Mensaje original-----
De: DOD [mailto:dcodea at] 
Enviado el: Viernes, 29 de Febrero de 2008 05:18 a.m.
Para: mathgroup at
Asunto: [mg85967] Creating Palettes

I've just tried to create a palette in v6, it is much harder than it
was in v5- is there a reason I can no longer "create a palette" from
the edit menu, and then "generate from selection"?  Anyway, I figured
out the tedious way to do it v6, but it won't create buttons I want:

CreatePalette[{PasteButton[a^2], PasteButton[b^2],
   PasteButton[a^3], PasteButton[b^3],
   PasteButton[(1 - a)], PasteButton[(1 - b)],
   PasteButton[(1 - a)^2], PasteButton[(1 - b)^2],
   PasteButton[(1 - a)^3], PasteButton[(1 - b)^3]

The parentheses around "(1-a)" and "(1-b)" are never created when I
press the buttons, only "1-a" and "1-b", which is obviously a problem
if I'm multiplying things.  This defeats the purpose of the palette
saving keystrokes.  Is there anyway to do this?

  • Prev by Date: Re: Re: how format vertex, edge labels in ShowGraph (Mathematica
  • Next by Date: Re: how insert hyperlink to doc paclet in ordinary notebook?
  • Previous by thread: Re: Creating Palettes
  • Next by thread: 6.0.2 Standard Palettes in Windows Vista