RE: Creating Palettes
- To: mathgroup at smc.vnet.net
- Subject: [mg86172] RE: [mg85967] Creating Palettes
- From: "Jose Luis Gomez" <jose.luis.gomez at itesm.mx>
- Date: Tue, 4 Mar 2008 02:10: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 -----Mensaje original----- De: DOD [mailto:dcodea at gmail.com] Enviado el: Viernes, 29 de Febrero de 2008 05:18 a.m. Para: mathgroup at smc.vnet.net 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?